InstallShield 2019 » InstallScript Language Reference
The VarRestore function reassigns the values that were saved by an earlier call to the VarSave function to the system variables TARGETDIR (in InstallScript installations), INSTALLDIR (in Basic MSI and InstallScript MSI installations), SRCDIR, or HKEYCURRENTROOTKEY. Call VarSave whenever you need to change the value of these system variables temporarily, for example, to set source and target directories before a call to XCopyFile. Afterwards, set those variables back to their previous values by calling VarRestore.
Syntax
VarRestore ( nType );
Parameters
Parameter |
Description |
||||||||||||||||||||||||
nType |
Specifies which system variables to restore. Pass one or more of the following predefined constants in this parameter. Note that you can pass multiple constants separated by the OR operator (||). Project • These constants apply to InstallScript projects:
Project • This constant applies to Basic MSI, InstallScript, and InstallScript MSI projects:
Project • This constant applies to Basic MSI and InstallScript MSI projects:
|
Return Values
Return Value |
Description |
0 |
Indicates that the previously saved values of the system variables were restored. |
< 0 |
Indicates that there are no values in storage to be restored. This error occurs if you call VarRestore without calling VarSave first, or if you call VarRestore more times than you call VarSave. |
Additional Information
Each time you call VarSave, the InstallScript engine pushes the current values of the system variables onto an internal stack, which operates as a last in, first out storage area. This method allows you to stack a series of values in memory. You can then make calls to VarRestore to retrieve those values from the stack in the opposite order that you stored them.
For example, if you call VarSave three times with SRCTARGETDIR as its argument (without calling VarRestore in between those calls), there will be three sets of SRCDIR and TARGETDIR values on the stack. The first call to VarRestore with SRCTARGETDIR as its argument restores the values from the third call to VarSave. The next call to VarRestore restores the values from the second call to VarSave. The third call to VarRestore restores the values from the first call to VarSave. At that point, the stack is empty. To see a script fragment that illustrates this process, refer to VarSave Stack Example.
See Also
InstallShield 2019 Help LibraryApril 2019 |
Copyright Information | Flexera |