
Commands - 103
READ
Statement
SYNTAX: READ variable [,variable] . . .
PURPOSE: To read values fr om a D ATA statement and assign them to variables. Se e the DA TA statement.
REMARK S: A READ statement m ust always be used in conjunction with a D ATA statement. READ statem ents
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 sever al REA D statem ents may access the sam e DATA statement. If the numb er of var iables is
fewer than the number of elements in the D ATA statement(s), subsequent READ statements w ill
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 READ s the values from the DATA statements into array A. A fter 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 RE ADs exceed the number of data
Commenti su questo manuale