Template Engine language reference > Directives > The #set directive

The #set directive
The #set directive establishes the value of a variable:
#set($variable=arg)
Note:
You cannot use #set to create arrays.
The left hand side of the assignment must be a variable. The right hand side of the assignment can be one of the types shown in the table below.
#set($myvariable = $mystring)
#set($mystring = 'myvalue')
#set($myint = 132)
#set($mydouble = 15.5121)
#set($mybool = false)
#set($mybool = true)
The right hand side of the assignment can also be a simple mathematical expression:
#set( $value = 1 + 2 )
#set($value = 3.5+5.0*3/2)
#set($value = (3.5 + 5.0)*3/2)
#set( $value = $bar - 1 )
#set( $value = $foo * $bar )
#set( $value = $foo / $bar )
Precedence
The standard order of operations, or precedence, when using mathematical expressions in a #set directive is as follows:
1
2
3
This means that if a mathematical expression is preceded by one operator and followed by another, the operator higher on the list should be applied first. The commutative and associative laws of addition and multiplication allow terms to be added in any order and factors to be multiplied in any order, but mixed operations must obey the standard order of operations.
OpenText StreamServe 5.6 Updated: 2013-03-01