| **Navigation:**  [[introduction.htm|Language Reference]] > 13 - Built-in Functions >====== RESTORESTATE (restore state of data file) ====== | [[reset reset record sequence position .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[resume resume thread execution .htm|{{btn_next_n.gif|Next page}}]] | | || **RESTORESTATE(**//file, savedstate,<;restoreflag>//**)** {{blk2blue.jpg|blk2blue.jpg}} | **RESTORESTATE** | Restores a file's //savedstate //state including the record buffer, file pointer, file sequencing order, and the error state of the system. | | //file// | The label of a FILE declaration. | | //savedstate// | A LONG numeric variable which represents the value returned by the GETSTATE procedure. | | //restoreflag// | A BYTE value that sets whether or not the file's record buffer is to be restored. The default value is FALSE (0), which indicates that the file buffer is not restored. | **RESTORESTATE** restores a file's state including the file pointer, file sequencing order, and the current error state of the system. By default, **RESTORESTATE** does not restore the file's record buffer. Setting the //restoreflag// to TRUE will restore the state of the file's record buffer. RESTORESTATE does not change the data stored in a file. If data is added to a file after GETSTATE and before RESTORESTATE, the new record(s) will remain in the data file after the RESTORESTATE. **Example:** **MyFunction PROCEDURE(FILE MyFile)** **CurState LONG** **  CODE** ** ! File will be in the same state on exit of this procedure as it was on entry** ** CurState = GETSTATE(MyFile)       !save current state of file** ** SET(MyFile)                       !ready to access file** ** NEXT(MyFile)                      !read a record** ** CLEAR(MyFile)                     !clear record buffer** ** ****RESTORESTATE****(MyFile,CurState,1)   !restore file and buffer to initial state** ** FREESTATE(MyFile, CurState)       !release resources** **See Also:** [[freestate free resources .htm|FREESTATE]] [[getstate return current state of data file .htm|GETSTATE]]