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

^if( condition )^


Code Type: 

Code Scope of Action: 

Code First Added: 

Code Altered: 

 Conditional Mark-up   [other codes of this type]

 n/a   [codes with similar scope]

 Baseline

 format"


^if( condition )^

Test if the condition is true, then includes everything from the ^if statement to the ^else^ or the ^endif^. If the else/endif mark-up is omitted the text following the closing ) bracket of the condition is returned. These are functionally the same:

Whilst the usual way to test for the existence of an object or group remains

^if(^exists(children)^)^

…the shorter test syntax

^if(^children^)^

works as well — i.e. if a note has any descendants, then ^children^ is true.

Note there is no 'else if' branching syntax; for such tests nest if statements.

The export element ^if^ accepts agent query expressions in the condition. For example,

^if(Name(tbx))^ 

…is true if the note's title contains the string "tbx",

^if(!Name(tbx))^ 

…is true if the note's title does not contain the string "tbx", and

^if(Width>5)^ 

…is true if the note's width exceeds 5.0

For the first two examples above the value matched can be an actual string or a regular expression.

In the ^if^ condition, the agent query is always evaluated in the context of this note.

A slightly different if syntax should used in Actions and Rules: if(query){action list}else{action list}. This syntax can only be used internally in Actions and Rules. In such context, either if syntax may be used but the ^if version, with carets, is the only one that may be used in export templates.