210
Platforms
©2000-2008 Tibbo Technology Inc.
dim
r1
as
real
dim
s
as
string
s="456.125"
r1=strtof(s)
'r1 will be equal to 456.125. This conversion will be done
without errors.
s="123.200"
r1=strtof(s)
'123.200 will be converted with errors. Actual result will be
123.25.
r1=s
'implicit invocation. Same result as for the line above.
Val Function
Function:
Converts string representation of a value into 16-bit value
(word or short).
Syntax:
val (byref sourcestr as string) as word
See Also:
,
,
,
,
,
,
Part
Description
sourcestr
String to convert.
Details
Recognizes &b (binary) and &h (hexadecimal) prefixes. Can be invoked implicitly,
through the word_var= string_var expression (see example below). Compiler is
smart enough to pre-calculate constant-only expressions involving implicit use of
val function.
Beginning with release
2.0
, this function also plays the role of vali function, which
has been removed.
Examples
dim
w
as
word
dim
sh
as
short
dim
s
as
string
s=
"&hF222"
w = val(s)
'explicit invocation, result will be 61986
sh= val(s)
'explicit invocation, result will be -3550 (sh is a 16-bit
signed variable)
w = s
'implicit invocation
w =
"2402"
'be calculated at compilation -- no actual val function
invokation will be here
Vali Function
Vali function is no longer available. Use
function both for unsigned (word)
and signed (short) conversions.
207
199
208
200
190
197
195
199
200
210