Conditional Actions (if clauses)

Tinderbox Icon

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 

[Last updated: 14 Dec 2009, using v5.0]

Google search aTbRef for:  

Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
[See aTbRef CC licence Attribution/Waiver info info]

Creative Commons License

Made with Tinderbox