VAL VALue
Function
VAL changes a string with a numeric value contained within into a number.
How to use VAL
VAL is followed by a string constant or variable, for example
70 LET x=VAL a$
The value of the string constant or variable is stripped of its quotation marks, and must then be a numeric value. VAL then evaluates this, returning it as a numeric value.
Examples
If a$ has the value "435" then the above statement assigns a value of 435 to x. However, VAL can also evaluate expressions, for example
10 INPUT a$,x
20 PRINT VAL a$
The string value that is assigned to a$ should be an expression using x, for example "x*x". A numeric value is then assigned to x, for example 5. VAL strips the quotation marks from the string value to get x*x and evaluates it using the value assigned to x, displaying the result 25.
Format
- VAL string-const
- VAL string-var
- VAL (string-expr)
See also