Assign

Top  Previous  Next

 

The Assign command allows you to set or clear the value of an existing Variable that can then be used within the script. If you should need to assign or reset the value of a Variable during processing, the Assign command gives you that functionality.

lamp Important: The Assign command can ONLY be used with existing variables that have already been declared in the script. To create a new variable use the Var command.

A common use for this is to declare a value that can be compared at a later point to determine whether some action has been taken. For example, you might create an initial FileSaved variable with the value False in the Setup Section so that it is global in scope, and then change the value to True in a User Section once the file has been successfully saved. You could then use a Conditional Command to take a further action in a later section only if the value is set to True, such as deleting the file.

 

Command Syntax

 

Assign:[VariableName],[VariableValue]

 

The colon after the command and the comma sign between parameters are compulsory. Any additional spaces or characters will cause an error to be thrown. The command itself is not case sensitive, but parameters may be depending on the operating system and locale.

 

Parameters:

 

VariableName: The name used to identify the Variable

VariableValue: The value to be assigned to the Variable

 

All parameters are compulsory. If any parameter is missing or invalid an error will be thrown.

 

Example:

 

[Setup]

Var:FileName,"C:\MyFile.txt"

Var:FileSaved,False

 

[Save]

Exec:FileSaver,%%FileName%%

Assign:FileSaved,True

 

[Finally]

If:VarEquals,FileSaved,True,DeleteFile:%%FileName%%

 

See Also: Special Functions Variables Subs