This version is out of date, covering development from v9.5.0 to v9.7.3. 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 v9 Icon

Short Boolean form for testing attribute values

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 query where all note's whose title does not include the string "Test" are matched.

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, thus 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; see also use of the |= operator.