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

|= (logical OR assigment)


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Altered: 

 Operator   [other Operator type actions]

 Item   [operators of similar scope]

 Assignment   [other Assignment operators]

 Already in v5.0.0

 


To make it easier to write rules succinctly, you may use the assignment:

$TheAttribute |= expression; 

…which sets $TheAttribute to true if it is already true, or if the expression is true. Thus, if $TheAttribute is false, the expression is not checked and the overall result is false. An attribute that has no value set (or inherited) is evaluated as false.

In practical terms this means the left side, usually an attribute - is set to the right side value only if it isn't already set at note level, i.e. its current value is either:

Attribute data type doesn't have to be Boolean

This fact makes the |= usage very useful for doing things like making code run only once - on the second pass the left side already has a value so no change occurs. This avoids things like looping causing multiple concatenation of strings.

For example:

$Urgent |= any(children,$Urgent) 

A project is urgent if it has been declared to be urgent itself, or if any child is urgent.

Consider three different notes and their $Color. The first is new and uncustomised, $Color is the default. The second has a prototype setting $Color to "green". The third has been manually set to "bright blue" by the user. If this action is applied to all three notes:

$Color |= "bright red" 

then two of the three notes will recolour. The first is has a default $Color so changes. The second note is green, but only because that is the default inherited via its prototype; it too, is re-coloured as it currently uses a default value. The third note is bright blue and this was expressly set at note level. So, as the latter doesn't use a default value, it remains bright blue.

If using |= assignments, it can be useful to have a means to reset an attribute to default to reenable an |= value assignment.

See also the logical AND assignment.


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


A Tinderbox Reference File : Actions & Rules : Operators : Action Operator Functional Types : Operator actions : |= (logical OR assigment)