eval

Evaluates the contents of a string as an expression.

Syntax

eval(str_expr)

Input

str_expr
A string expression

Example

Example 1
Template:
{formula = "1 + 1"}
{eval(formula)}
Output:
2
Example 2
Template:
{eval("sin(PI/2)")}
Output:
1

Comments

When Templex encounters an eval statement, str_expr is evaluated as an expression and the result is written to the output text. The contents of str_expr are not changed.

str_expr can be either a literal text string or a string variable. If str_expr is a literal text string, it must be placed between double quotes.