Difference between revisions of "RESTORE"

From BeebWiki
Jump to: navigation, search
(Draft initial page.)
 
m (Added category.)
 
Line 1: Line 1:
 +
[[Category:BASIC keywords]]
 
RESTORE
 
RESTORE
  

Latest revision as of 05:44, 16 March 2017

RESTORE

RES. A statement which moves the data pointer. RESTORE can be used at any time in a program to set the line from where READ reads the next DATA item.

RESTORE on its own resets the data pointer to the first data item in the program.

RESTORE followed by a line number or label sets the data pointer to the first item of data in the specified line (or the next line containing a DATA statement if the specified line does not contain data). This optional parameter for RESTORE can specify a calculated line number.

RESTORE followed by a plus sign (+) and a positive numeric value sets the data pointer to the first item of data in the line offset from the line containing the RESTORE statement by the specified number of lines (or the next DATA statement if the specified line does not contain any data). When using values greater than +1 it is advisable to put the DATA statements immediately after the RESTORE statement to avoid incorrect results if the program is compiled.

   RESTORE
   RESTORE 100
   RESTORE +2
   RESTORE (10*A+20)
   RESTORE (mydata)

You can use RESTORE to reset the data pointer to the start of your data in order to re-use it. alternatively, you can have several DATA lists in your program and use RESTORE to set the data pointer to the appropriate list.

RESTORE DATA RESTORE DATA causes the DATA pointer saved by a previous LOCAL DATA statement to be restored from the stack.

RESTORE ERROR RESTORE ERROR causes the error-trapping status saved by a previous ON ERROR LOCAL statement to be restored from the stack.

RESTORE LOCAL RESTORE LOCAL (which can be used only inside a user-defined procedure or function) restores the values of formal parameters and LOCAL/ PRIVATE variables to those they had before the procedure/function was called. RESTORE LOCAL also performs the action of RESTORE ERROR. This is primarily intended for use within an ON ERROR LOCAL error handler.

Syntax

   RESTORE [<l-num>]
   RESTORE [(<numeric>)]
   RESTORE +<numeric>
   RESTORE DATA
   RESTORE ERROR
   RESTORE LOCAL

Associated Keywords

   READ, DATA, ON ERROR LOCAL