This version is out of date, covering development from v4.6.0 to v4.7.1. It is maintained here only for inbound reference links from elsewhere. Jump to the current version of aTbRef. |
|
A Tinderbox Reference File : Actions & Rules : Conditional Actions (if clauses) | aTbRef Site Map |
Conditional Actions (if clauses) |
In rules and actions, Tinderbox uses this conditional action syntax:
if(expression) { action-list }
if (expression) {action-list} else {action-list}
Where:
Example:
if ($ChildCount>5) { $Color="red";$Width=3.5} else {$Color="blue"}
The testing for negatives may be done several way. For an attribute value test, the atttribute name may simply be prefixed is an exclamation mark:
if(!$MyString){...etc.
Otherwise the != operator is used:
if($MyString!="some value"){...etc.
The remainder of this note refers to deprecated usage.
Although the export code ^if syntax is deprecated in actions and rules, though if used it may still be correctly detected.
Note the slight difference between the two two conditional syntaxes. The export code ^if version evaluates a conditional test for a resolved value of true. The newer if version evaluates an action code expression ( previously a query - i.e. as written in an agent) test also for a resolved value of true. While both ultimately test for a true result, the initial test may need to be written slightly differently for each version.
Note that in the action code conditional syntax the $Attribute=value assignation is made inside the {} brackets. Conversely, the older ^if syntax requires the a single left hand Attribute= with the alternate values embedded i the if statement at right side. Thus, new:
if(conditional expression){$Attribute="value1"}else{$Attribute="value2"}
... versus old (now deprecated):
$Attribute=^if(condition)^value1^else^value2^endIf^
The new syntax makes testing for negatives much easier than using ^not, as an attribute name may simply be prefixed is an exclamation mark:
if(!$MyString){...etc.
Both the above work but using a $ prefix for attribute names is perhaps better for long-term maintenance as the syntax is explicit.
Up: Actions & Rules | |
Previous: Compound Actions | Next: Conditional statements using multiple arguments |
Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
[See aTbRef CC licence Attribution/Waiver info info]