READ
Purpose
Reads the contents of the DATA statement into memory.
READ Variable name [ , Variable name ]*
Example
READ A, B
READ C$, X, Y
Parameters
Variable name
Explanation
- Assigns the data contained in a DATA statement to the variables
on a one-by-one basis.
- Numeric data can only be assigned to numeric variables, and string data
can only be assigned to string variables. A TM error is generated when an
attempt is made to assign string data to a numeric variable, and vice versa.
- The data in DATA statements is read from the lowest line
number in ascending order. Data are read in order from the beginning of a
DATA statement. Subsequent executions read data items in
sequential order.
- The first execution of the READ statement reads the first data item contained
in the first DATA statement. Subsequent executions read data items
in sequential order.
- The data line to be read can be specified using the RESTORE
- statement.
See
Sample Program
10 READ X
20 IF X <> 0 THEN PRINT X;: GOTO 10
30 END
100 DATA 1,2,3,4,5,6,7,8,9
110 DATA 9,8,7,6,5,4,3,2,1
120 DATA 0
Sequentially reads data beginning at line 100 and stops execution when 0
is encountered as data.