Show/Hide Toolbars

XSharp

NoteThis command is not available in the Core and Vulcan dialects
NoteThis command is defined in a header file and will be preprocessed by the X# preprocessor to a function call. If you disable the standard header (-nostddefs) files then this command will not be available. If you tell the compiler to use a different standard header file (-stddef ) then this command may also be not available

Purpose

Recreate public and private variables previously saved to a file and initialize them with their former values.

Syntax

RESTORE FROM <xcSourceFile> [ADDITIVE]

Arguments

<xcSourceFile>The name of the memory file (created, for example, with SAVE), including an optional drive, directory, and extension.  See SetDefault() and SetPath() for file searching and creation rules.  The default extension is .MEM.
 
This command attempts to open <xcSourceFile> in shared mode.  If the file does not exist, a runtime error is raised.  If the file is successfully opened, the operation proceeds.  If access is denied because, for example, another process has exclusive use of the file, NetErr() is set to TRUE.  

 

ADDITIVECauses memory variables loaded from the memory file to be added to the existing pool of memory variables.

Description

The scope of the variable is not saved with the variable but is instead established when the variable is restored.  Arrays and declared variables cannot be saved or restored.

 

When memory variables are restored, they are recreated as private variables with the scope of the current procedure or function unless they exist as public variables and you specify the ADDITIVE clause .  If ADDITIVE is specified, public and private variables with the same names are overwritten unless hidden with PRIVATE.  If ADDITIVE is not specified, all public and private variables are released before the memory file is loaded.

 

When restoring variables that were saved in a CLIPPER program, the variable names are truncated to 10 characters.  This is because CLIPPER honors only the first 10 characters and generates the .MEM file using only these characters.  XSharp, however, honors all characters.  For example, in CLIPPER, the two variable names ThisIsALongVariable and ThisIsALon refer to the same variable; this is not the case in XSharp.

 

Note: Declared variables are not affected by the RESTORE command.  If a variable has been declared in the current routine, and a variable with the same name is restored, only the declared variable is visible unless references to the restored variable are prefaced with the _MEMVAR-> alias.

Examples

This example demonstrates a typical application of SAVE and RESTORE.  Here memory variables containing screens are created using SAVE TO and RESTORE FROM:

 

// Create and use a pseudo array of screens
SAVE SCREEN TO cScreen1
SAVE ALL LIKE cScreen* TO Screens
 
<Statements>...
 
RESTORE FROM Screens ADDITIVE
nNumber = "1"
RESTORE SCREEN FROM ("cScreen" + nNumber)

Assembly

XSharp.RT.DLL

See Also

LOCAL, PRIVATE, PUBLIC, SAVE, SetDefault(), SetPath()