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:

str, lstr, stri, lstri, bin, lbin, hex, lhex, lval


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

** 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