1. A newbie question
If I read a record from a file with gets it is stored in a sequence, one
character per element. If part of the record represents numeric data,
e.g. a dollar amount, how can I convert the slice of the sequence
containing "12.34" into the number 12.34 so that I can do arithmetic
with it?
Thanks,
Philip.
2. Re: A newbie question
- Posted by "Thomas Parslow (PatRat)" <patrat at INAME.COM>
Sep 11, 2000
-
Last edited Sep 12, 2000
> If I read a record from a file with gets it is stored in a sequence, one
> character per element. If part of the record represents numeric data,
> e.g. a dollar amount, how can I convert the slice of the sequence
> containing "12.34" into the number 12.34 so that I can do arithmetic
> with it?
> Thanks,
> Philip.
Hi,
include get.e
constant string="12.34"
atom number
number = value(string)
Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.ratsoft.freeserve.co.uk/
Please leave quoted text in place when replying
3. Re: A newbie question
>> If I read a record from a file with gets it is stored in a sequence, one
>> character per element. If part of the record represents numeric data,
>> e.g. a dollar amount, how can I convert the slice of the sequence
>> containing "12.34" into the number 12.34 so that I can do arithmetic
>> with it?
>> Thanks,
>> Philip.
> Hi,
> include get.e
> constant string="12.34"
> atom number
> number = value(string)
Hi,
That should have been:
include get.e
constant string="12.34"
object number
number = value(string)
--number now equals {error status,value} or {GET_SUCCESS,12.34}
if number[1] = GET_SUCCESS then
--success
number = number[2]
? number
else
--failed
end if
Thanks to CK Lester for pointing this out :)
Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.ratsoft.freeserve.co.uk/
Please leave quoted text in place when replying
Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.ratsoft.freeserve.co.uk/
Please leave quoted text in place when replying