Evaluation Order of Functional Expressions

Evaluation Order of Functional Expressions

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

Evaluation Order of Functional Expressions

Functional expression are evaluated in stages. Evaluation starts with the most nested argument, and works outwards. If the innermost nest consists of several arguments, the arguments are evaluated from left to right. To change the order of evaluation, use parentheses to change the nesting level.

Consider the following example:

$minof($left(TelNo,3),var1+var2)

Because TelNo is the first argument of the innermost nest, the value of TelNo is determined first. If TelNo is a character-type field whose value is ‘416-555-1212’, then the expression is treated as if it reads

$minof($left(‘416-555-1212’,3),var1+var2)

The other arguments of the innermost nest are literals, so $left is now evaluated, returning the result ‘416’, a character string. The expression is now treated as if it reads

$minof(‘416’,var1+var2)

If the value of var1 is 400 and the value of var2 is 1, then the second argument of $minof evaluates to 401:

$minof(‘416’,401)

Because one of the operands of the $minof function is numeric, all the other operands must be converted. The character string ‘416’ is therefore converted to the number 416:

$minof(416,401)

Finally, the $minof function is applied, returning the result 401.

Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_CAEnglish