# VAL

 BASIC keyword Keyword: VAL Abbreviation: V, Shift+A Type: Function Token code: 197/\$C5 Handling routinein BASIC ROM: 47021–47082\$B7AD–B7EA List of all BASIC keywords

Remark: This article describes the BASIC command VAL in BASIC V2 at the Commodore 64.

Type: Numeric Function
General Programming-Syntax: VAL(<String>)

The function VAL finds a numerical value in a string. Space chars and the first minus- (-) and plus-char (+) are ignored. The first minus char is interpreted as negative prefix. The searching of the numerical value stopped, when the first non-numerical char is reached. The first dot (.) is interpreted as decimal point and the first e or E as exponent. Mathematical terms and arithmetic operation are ignored.

When the argument isn't a string, appears the BASIC error ?TYPE MISMATCH ERROR IN line. It can be only processed numbers with values from -1e+38 until 1e+38. Then this area is out of range the BASIC error ?OVERFLOW ERROR IN line is viewing. When the argument is absent, it appears a ?SYNTAX ERROR IN line.

## Examples

PRINT VAL("A1") Screen: 0
PRINT VAL("- 1 2 3 . 2 3 4 e + 23) Screen: -1.23234e+25
PRINT VAL("1051 E-3 -1.051 C) Screen: 1.051
BASIC V2.0 (second release) Commands

ABS | AND | ASC | ATN | CHR\$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT\$ | LEN | LET | LIST | LOAD | LOG | MID\$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | π | POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT\$ | RND | RUN | SAVE | SGN | SIN | SPC | SQR | STATUS/ST | STEP | STOP | STR\$ | SYS | TAB | TAN | THEN | TIME/TI | TIME\$/TI\$ | TO | USR | VAL | VERIFY | WAIT