This version is out of date, covering development from v5.0.0 to v5.12.2. It is maintained here only for inbound reference links from elsewhere.

Jump to the current version of aTbRef.

Tinderbox Icon

Short Boolean form

It is possible to cite attribute tests in both a long form:

if($MyBoolean == true) 

if($MyBoolean != true) 

or a simple short form:

if($MyBoolean) 

if(!$MyBoolean) 

Note in the negative version the '!' moves in front of the attribute name (and the $-prefix). Thus !$MyString means $MyString has no value set whilst !$Name(Test) causes a reverse pattern query where all note's whose title does not include the string "Test" are matched.

Prior to v5.0.0 the short form failed in certain contexts and it was advisable to use the 'full' syntax; this requirement should not fall away allowing shorter code. Prior to v5.5.4, the negative form was misinterpreted if not the first argument in the expression.

Though the short form is primarily for Boolean attributes, where another data type can be coerced to a true/false equivalent the short form may be tried. the coercion being tested depends on the attribute type's default value. Any value other than the default, results in a coercion of true. $ChildCount is a number type attribute so the default is zero. Both the code examples below equate to the same test but the latter is shorter - useful in longer, more complex expressions.

if($ChildCount > 0) {… if($ChildCount) {…

The converse would be:

if($ChildCount < 1) {… if(!$ChildCount) {…

Note that the short Boolean form, whilst coercing non-Boolean type values to a true/false occurs it is not testing whether the default value is inherited or was explicitly set; qv use of the |= operator.


Possible relevant notes (via "Similar Notes" feature):


A Tinderbox Reference File : Actions & Rules : Short Boolean form