VAL$

BASin

VAL$ VALue (string)

Function

VAL$ evaluates a string as a string expression.

How to use VAL$

VAL$ is followed by a string variable, for example

130 PRINT VAL$ a$

The value of the string variable is stripped of its quotation marks, and must then be a string expression. VAL$ evaluates the expression and returns the value as a string constant.

Examples

Try this program

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 string value is then assigned to x$, for example "DO". VAL$ strips the quotes of the value of a$ to get x$+x$ and evaluates it using the value assigned to x$, displaying the result DODO.

Format

  • VAL$ string-var
  • VAL$ string-const
  • VAL$ (string-expr)