value
| Definition: |
include get.e
sequence s = value(string st) |
| Description: | Read the string representation of a phix object,
and compute the value of that object. A 2-element sequence,
{error_status, value} is actually returned, where error_status
can be one of:
GET_SUCCESS -- a valid object representation was found
GET_EOF -- end of string reached too soon
GET_FAIL -- syntax is wrong
|
| pwa/p2js: | Not supported, see scanf() instead. |
| Comments: |
This works the same as
get(), but it reads from a string
that you supply, rather than from a file or device.
After reading one valid representation of a phix object, value() will stop reading and ignore any additional characters in the string. For example, "36" and "36P" will both give you {GET_SUCCESS, 36}. Note this is an "inherited" routine, that I don’t much like. Whenever I try to use it, I tend to get stuck, give up, and roll my own. However if it works for you, then fine. |
| Example 1: |
s = value("12345")
-- s is {GET_SUCCESS, 12345}
|
| Example 2: |
s = value("{0, 1, -99.9}")
-- s is {GET_SUCCESS, {0, 1, -99.9}}
|
| Example 3: |
s = value("+++")
-- s is {GET_FAIL, 0}
|
| See Also: | get, sprintf, print, scanf |