``

prev Menu next

READ, DATA ☆☆☆
`READ`
assigns the data written in the DATA statements to the variables.
`DATA`
DATA Statements describes the data that shall be read by the READ statements.
The data items are written in DATA statements punctuated by commas.
The data may extent over more than one DATA statement.
In that case, unlike a input reply, no comma is put on the tail.
Example 1.

    10 DATA 34,78,13,54
    20 READ a,b,c,d

Example 2.

    10 DATA 34,78
    15 DATA 13,54
    20 READ a,b,c,d

Example 3.

    10 DATA 34,78,13,54
    20 READ a,b
    25 READ c,d

Data items that is to be assigned to string variables are written enclosed in double quotation marks.
Example.
`10 DATA "Tanaka",168
20 READ N$,L
`
On some conditions, data items can be written unquoted. For detail, see the Full BASIC standard.
Example
`10 DATA "I am a boy." , ABC
20 READ A$,B$
30 PRINT A$,B$
40 END
`

All the items written in the DATA statements of a program unit forms a single sequence of data.
Data items are read in written order in the program unit.
`RESTORE`
let the READ statement that shall be executed next read from the first item.
RESTORE line_number
The READ statement that shall be executed next shall read from the item located in the DATA statement that is labeled line_number .

Note.
The scope of DATA statements is the program unit.
Data is independent for each program unit.