![]() ZBasic System Library
337
ZBasic Microcontrollers
Type
Subroutine
Invocation
ValueS(str, val, flag)
Parameter
Method
Type
Description
str
ByVal
String
The string from which to extract a floating point value.
val
ByRef
Single
The variable to receive the value.
flag
ByRef
Boolean
The variable to receive a success indicator.
Discussion
This routine converts a character representation of a floating pointer number, contained in the str
parameter, to a Single value returned in the val parameter. If the string is in an acceptable format, the
flag parameter is set to True. Otherwise, the flag parameter is set to False and the val parameter
will be 0.0.
The string may contain any number of leading and/or trailing spaces. The value itself may consist solely
of decimal digits or may have a leading plus or minus sign. The value may include a decimal point, with
or without preceding digits. However, there must be a digit either preceding the decimal point or following
it, or both. Optionally, there may be a multiplier value consisting of the letter E (upper or lower case),
optionally followed by a plus or minus sign, followed by one or more digits. Note that the range of
acceptable input is wider than that for real values in ZBasic statements.
If the provided string has the proper format but represents a value that is too large or too small to be
represented as a Single, the result will be invalid but no such indication will be given.
Examples of floating point numbers accepted by ValueS() are:
.30103
3.14159
-200.
1e05
+6.02E+23
123
See Also
Value, ValueL
|