READ reads values from DATA statements instead of the keyboard. DATA statements contain string and/or numeric constants separated by commas. This provides a convenient method of embedding known data that your program requires, right in the program itself. The first READ statement in a context reads the first DATA statement in that context. A pointer is maintained to the next item in the DATA statement. The DATA pointer can be reset to the beginning of any DATA statement in the context with the RESTORE statement.
READ statements can be useful for initializing the values of several program variables more compactly than with individual [LET] assignment statements. It is also handy for table data that you can READ into an array.
The following example shows the use of the DATA, READ and RESTORE statements.
100 DATA 1,2,"STRING CONSTANT",10
110 READ A,B,A$,C ! read data from line 100
120 DATA 13,24,36,42,59
130 DIM D(4),E(4)
140 READ D(*) ! read array data from line 120
150 MAT D=D*(B)
160 RESTORE 120
170 READ E(*) ! read data from line 120 again
180 END
Note that line 160 specifies line 120 as the data statement to be restored since there is a previous data statement in line 100. If line 120 were the first data statement in the program, line 160 could be simply RESTORE with no line number.