Conditional Actions (if clauses)

Tinderbox Icon

From v3.0.0, in rules and actions, Tinderbox now accepts a new syntax for conditional actions

   if(query) { action-list }

   if (query) {action-list} else {action-list}

Where:

Example:

if (ChildCount>5) { Color=red;Width=3.5} else {Color=blue}

The original ^if syntax, may still be used in Actions and Rules if preferred.

Note the slight difference between the two forms. The ^if version evaluates a conditional test for a resolved value of true. The newer if version evaluates 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 new 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(query){Attribute=Value1}else{Attribute=Value2}

... versus old:

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.

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: Expressions in paths 

[Last updated: 3 Dec 2008]

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