| |
|
| Formats |
NUM(string$
[ , errval ] [,ERR=stmtref])
Where:
|
| |
string$ |
Character
string whose value is to be converted to a numeric value.
Numeric in string expression (e.g.,
"19990317"). |
| |
|
|
| |
errval
|
Value to
return if string$ is not numeric. Optionally can
be an asterisk to test string$ - See Numeric String
Testing. |
| |
|
| |
stmtref |
Program line
number or statement label to which to transfer control. |
| |
|
| Returns |
Numeric
value from string. |
| |
|
| Description |
The
NUM( ) function returns the numeric
value of a numeric expression in a string (e.g., 19990317 from
"19990317"). The string is evaluated and
converted to a numeric value. If the value in string$ does not
contain a valid numeric value, ProvideX returns an Error
#26: Variable type invalid.
Your string expression can
include any number of the following valid characters:
0-9, a space, a comma, an equals sign, or a dollar sign.
You can also include one decimal point along with one
sign character (either
'-' or '+').
NUM( ) always
ignores the decimal point and thousands separator
settings in the 'DP'
and 'TH' system parameters.
|
| |
|
| Numeric
String Testing |
If
an asterisk ( * ) is used in place of errval,
the NUM ( ) function does not convert
the value of string$ but rather validates it can
be converted to numeric. It will return a '0' if the
value in string$ is not a valid numeric string,
or 1 if it is.
Numeric string
validation and use of errval are +PxPlus
Exclusive
|
| |
|
| Examples |
| A=NUM("1.34") |
Yields
1.34 |
| A=NUM("-1,005.") |
Yields
-1005 |
| A=NUM("A",ERR=50) |
On
error, transfers to 0050 and sets ERR=26 |
| A=NUM("A",1234) |
Yields
1234 |
| A=NUM("1.34",*)
|
Yields
1 |
| A=NUM("A",*) |
Yields
0 |
|