Saturday, July 6

RESTORE Statement

The restore statement allows DATA statements to be reread from a specified line.
Syntax
LN RESTORE [Line Number]
Where,
LN      :           Line Number
Line number    :       The particular line number from which data are to be read again.
  • if line number is specified the next READ statement reads the first data in the specifed DATA statement.
  • if line number is omitted, the next READ statement reads the first data in the first DATA Statement.
Example

10  RESTORE
Use the RESTORE Statement in program

CS 5.11 Display on the screen for RESTORE statement

2  REM  Learning use of RESTORE statement
5  READ A, B, C
10  RESTORE
15  READ D, E, F
20 DATA 1.8, 5.02, 8, 20, -47, 0.003
40 PRINT A, B, C, D, E, F
50 END

Explanation of the program
This program will assign the following values to the variables
A = 1.8
B = 5.02
C = 8
D = 1.8
E = 5.02
F = 8
The RESTORE statement results the pointer to the beginning of the line 20. 
In the absence of the RESTORE statement (i.e. line 10) , the following values would be assigned to the variables.
A = 1.8
B = 5.02
C = 8
D = 20
E = -47
F = 0.003      

No comments:

Post a Comment