This version is out of date, covering development from v7.0.0 to v7.5.6. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox 7 Icon

Parentheses as a guide to code execution

Although the order in which code is executed might seem intuitive to the user but this may not necessarily be how Tinderbox sees and interprets it. In such situations, parentheses (normal brackets) can be used to indicate 'sub-expressions'. Execution order of things like this

$AttrA($Num1) = $AttrB($Num1) + 1; 

can be less obvious to Tinderbox than to the user writing them. This is especially true where, like above, attribute expressions are being used as these require evaluating themselves before the main expression is evaluated.

In such circumstances, especially if tests appear to give the wrong answer, consider adding parenthesis as a guide to Tinderbox as to the order of the process. For instance:

$AttrA($Num1) = ($AttrB($Num1) + 1;) 

tells Tinderbox to evaluate the whole of the right side before attempting the overall expression.

Parentheses can also be useful in stopping mis-interpretation of multi-term queries including the short-form no-value attribute test, e.g. !$AttributeName. Using (!$AttributeName) instead of !$AttributeName) can help.

Beware too of data types and lack of clarity of whether a '+' is a (string) concatenation or a (number) addition; see more.



A Tinderbox Reference File : Actions & Rules : Parentheses as a guide to code execution