Page 1 of 1

Condition expression

Posted: 16 Jul 2014, 06:31
by PetrS
size=150Condition expression/size
Version 5.2.15 and higher

Conditional expression was implement in SDF. The conditional operator ( ? : ) returns one of two values depending on the value of a Boolean expression.

ubSyntax for the conditional operator:/b/u
i<condition> ? <first_expression> : <second_expression>/i

The condition must evaluate to true or false. If condition is true, first_expression is evaluated and becomes the result. If condition is false, second_expression is evaluated and becomes the result. Only one of the two expressions is evaluated.

You can express calculations that might otherwise require an if-else construction more concisely by using the conditional operator.

ubNote:/b/u
It is recommended to close the conditional expression in parentheses to make the code more readable.


See attached example for more info.