BASIC RESTORE Statement - fvdhoef/aquarius-plus GitHub Wiki

RESTORE

TYPE: BASIC Statement

FORMAT: RESTORE [line_number]

Action:

BASIC maintains an internal pointer to the next DATA constant to be READ. This pointer can be reset to the first DATA constant in a program using the RESTORE statement. The RESTORE statement can be used anywhere in the program to begin re-READing DATA.

When a line number is specified, the data pointer is set to the beginning of that line.

EXAMPLES of RESTORE Statement:

Fills the two arrays with identical data :

100 FOR X=1 TO 10: READ A(X): NEXT
200 RESTORE
300 FOR Y=1 TO 10: READ B(Y): NEXT

4000 DATA 3.08, 5.19, 3.12, 3.98, 4.24
4100 DATA 5.08, 5.55, 4.00, 3.16, 3.37

Prints the data twice:

10 DATA 1,2,3,4
20 DATA 5,6,7,8
30 FOR L= 1 TO 8
40 READ A: PRINT A
50 NEXT
60 RESTORE
70 FOR L= 1 TO 8
80 READ A: PRINT A
90 NEXT

Prints "LAST":

10 RESTORE 50
20 READ A$
30 PRINT A$
40 DATA FIRST
50 DATA LAST