#ASSIGN
Syntax
#ASSIGN(Variable, Expression)
Parameters
- Variable - The $Variable is the name of a new variable, or it can be a predefined variable which is having its value modified.
- Expression - A cScript expression to be evaluated and result assigned to the variable.
Description
Assigns the Expression result to the Variable. The Expression may be an integer, string or other data-type value, Expressions can include mathematical operations and many PHP and Perl built-in functions.
Unlike #NEW, if the expression is a content record (in other words, the field referenced by the variable has a Type set to a Content Type), that same value will be copied to the new variable.
This statement does not produce output.
Example - Assigning a String
To assign a string we must enclose the string in quotes.
#ASSIGN($B,"Text")
$B is the magic string.
Result
Text is the magic string.
Analysis
In this example, a new variable called $B is created and is set to the value Text.Example - Assigning an integer
#ASSIGN($A,3)
$A is the magic number.
Result
3 is the magic number.
Analysis
In this example, a new variable called $A is created and is set to the value 3.
Example - Math Operations
Assign is a variable that has already been set to 3 in Example 1.
#ASSIGN($A,$A+1)
The magic number is now $A.
Result
The magic number is now 4.