Specifications

Commands - 95
READ
Statement
SYNTAX: READ variable [,variable] . . .
PURPOSE: To read values from a DATA statement and assign them to variables. See the DATA statement.
REMARKS: A READ statement must always be used in conjunction with a DATA statement. READ statements
assign DATA statement values to variables in the READ statement on a one–to–one basis. READ
statement variables may be numeric or string.
A single READ statement may access one or more data statements (they will be accessed in order), or
several READ statements may access the same DATA statement. If the number of variables is fewer
than the number of elements in the DATA statement(s), subsequent READ statements will begin
reading data at the first unread element. If there are no subsequent READ statements, the extra data
is ignored.
To reread the DATA statements from the start, use the RESTORE statement. CLEAR also restores
the data pointer.
RELATED: DATA, RESTORE
EXAMPLE: 10 FOR X = 1 TO 9
20 READ A(X)
30 NEXT
40 DATA 153,124,5432,10,7,812,11
50 DATA 201,332,762,902,0,–34,69875
This program segment READs the values from the DATA statements into array A. After execution
the value of A(1) will be 153, and so on.
ERROR: <Syntax>– if data type does not match variable type
<Out of DATA>– if the number of READs exceed the number of data