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
This function recognizes the &b (binary) and &h (hexadecimal) prefixes. It can be invoked implicitly through the word_var = string_var expression (see example below). The compiler is smart enough to pre-calculate constant-only expressions involving implicit use of the val function.
Beginning with the release of TiOS 2.0, this function also plays the role of the vali function, which has been removed.
Examples
Tibbo BASIC
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