READ

From C64-Wiki

Jump to: navigation, search
BASIC keyword
Keyword:READ
Abbreviation:R, Shift+E
Type:Command
Token code:135/$87
Handling routine
in BASIC ROM:
44038–44283
$AC06–ACFB
List of all BASIC keywords


Remark: This article describes the BASIC-Command READ in BASIC V2 at the Commodore 64.

Typ: Command
General Programming-Syntax: READ <variable> [,<variable>]

The BASIC-command READ is using for reading constant informations from DATA-lines into the indicated variable. It can be readed more constants with one READ-command also seperated through commas.

By using the wrong type of variable (for example read a char into a numerical variable like floating point or integer) the BASIC-error ?SYNTAX ERROR IN line occurr with a reference of corresponding DATA-line. When general used string variables for reading these BASIC-error can be avoided. When more constants are reading than data informations are written in the DATA-lines the BASIC-error ?OUT OF DATA IN Zeilennummer appear.

The BASIC-command RESTORE clear the pointer for the next DATA-constant. The next read begins by the first DATA-constant !


[edit] Examples

10 DATA 1,2,3,Apple,"Commodore 64" 
20 READ A
30 READ B%, C, D$
40 READ E$
50 PRINT A, B%, C, D$, E$
10 FOR X=0 TO 10: READ A(X): PRINT A(X),;:NEXT
20 DATA 10,20,30,40,50,60,70,80,90,100,110
BASIC V2.0-Commands of Commodore 64

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

 
Personal tools
Help and Feedback
In other languages