Application icon

Evaluate Expression

The supplied mathematical expression is evaluated and returned in the specified variable or named variable. The supplied text strings may contain any of the escape sequences described in Escape Sequences.

The result can be forced to be an integer value by specifying the Return integers only option.

Specify numbers with decimal points and at least one fractional digit if you do not want only integer results. ie. 3.0 not 3 or 3. (which is considered invalid).

When including variables in the expression use the \I or \F forms as opposed to \V as they guarantee a properly formatted integer or number.

Example: (3 + \i1) * 5

The expression parser which Yate uses contains a number of standard functions which may be of use:

abs(#)
The absolute value of #
    abs(-2) ---> 2
    abs(2) ---> 2
ceiling(#)
The smallest integer greater than or equal to #
    ceiling(1.2) ---> 2
    ceiling(-1.2) ---> -1
floor(#)
The largest integer less than or equal to #
    floor(1.2) ---> 1
    floor(-1.2) ---> -2
trunc(#)
The value of # with any fractional part removed
    trunc(1.2) ---> 1
    trunc(-1.2) ---> -1

Yate also provides the following extensions. (We didn't design the syntax).

function(#1, 'div:', #2)
The integer division of expression #1 and expression #2, regardless of the presence of fractions.
    function(5, 'div:', 2.1) --> 2
    function(-5, 'div:', 2.1) --> -2
function(#1, 'mod:', #2)
The integer remainder of dividing expression #1 by expression #2.
    function(5, 'mod:', 2) --> 1
    function(-5, 'mod:', 2) --> -1
function(#1, 'max:', #2)
The maximum of expression #1 and expression #2
    function(5, 'max:', 2) --> 5
    function(-5, 'max:', 2) --> 2
function(#1, 'min:', #2)
The minimum of expression #1 and expression #2
    function(5, 'min:', 2) --> 2
    function(-5, 'min:', 2) --> -5

If any errors occur during the evaluation the action test state is set to false and the destination variable is set to zero. The action test state will be set to true upon a successful evaluation. When running in stepwise mode, the action test state will only be set to true if the evaluation succeeded for every track.

When running in stepwise mode, the expression is only evaluated once if the destination is a named variable.