Template Engine language reference > Functions > .toInt()

.toInt()
The .toInt() function converts a string or double floating point to an integer. This is useful, for example, when you need to perform calculations on field values retrieved from the Message. Field values are retrieved as strings, and if you want to perform calculations on these values you must first convert the strings to either double floating point (see .toDouble() below) or integers.
In both examples below, the value of $message.sum is "10".
Example 6
Template:
#set($a=$message.sum.toInt())
#set($b=$a+10)
$b
Output:
20
 
Example 7
Template:
#set($a=$message.sum)
#set($b=$a+10)
$b
Output:
1010
 
The .toInt() function can also be used to convert a boolean true/false to 0/1.
Example 8
Template:
#set($bool_1=true)
#set($bool_2=false)
$bool_1
$bool_1.toInt()
$bool_2
$bool_2.toInt()
Output:
true
1
false
0
 
OpenText StreamServe 5.6 Updated: 2013-03-01