VarSave

Product Feedback
Feedback

Syntax

VarSave (nType);

Description

The VarSave function saves the current values of the system variables SRCDIR and TARGETDIR, which are used by many other InstallScript functions. Call VarSave whenever you need to change the value of SRCDIR and TARGETDIR 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.

Parameters

nType

Specifies the constant SRCTARGETDIR to indicate that you want to save the current value of the system variables SRCDIR and TARGETDIR.

Return values

0

Indicates that the current values of SRCDIR and TARGETDIR were saved.

< 0

Indicates that the values were not saved due to an internal error. This error should occur only if the system is low on available memory.

Comments

Each time you call VarSave, InstallShield pushes the current values of SRCDIR and TARGETDIR onto an internal stack, which operates as a last in, first out storage area. This method allows you to stack a series of SRCDIR and TARGETDIR 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 (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 will restore the values from the third call to VarSave. The next call to VarRestore will restore the values from the second call to VarSave. The third call to VarRestore will restore the values from the first call to VarSave. At that point, the stack will be empty. To see a script fragment that illustrates this process, click here.


Example