- ⌂ Variables
- Directives
#ASSIGN
Assign the result of a cTemplate expression to a variable. The expression may be an integer, string or other data-type value. Expressions can also include mathematical operations and cScript.
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.
Prototype
#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 cTemplate expression to be evaluated and result assigned to the variable.
Examples
String Assignment Example
To assign a string, enclose the string in single- or double-quotes.
#ASSIGN($B,"Text")
$B is the magic string.
Integer Assignment Example
#ASSIGN($A,3)
$A is the magic number.
Math Operation Example
Assign is a variable that has already been set to 3 in Example 1.
#ASSIGN($A,$A+1)
The magic number is now $A.
Related
#APPEND to append the result of a cTemplate block to a variable.
#NEW to set a variable to the result of a cTemplate block.