Operator Scope of Action:
Operator First Added:
Operator Last Altered:
In action code contexts, an attribute's name prefixed with a $-character implies a reference to that attribute, thus a placeholder for that attribute's value. In a coding context is acts as a variable name where the variable name must be that of an existing attribute and the variable's value is got from or set to that attribute.
A reference on the right side of an expression fetches the attribute's value. A reference on the left side of an expression has its value set to the result of the right side. The following example combines these uses whereby in the current object (a note, agent, adornment, etc.), the user attribute $MyNumber is being set to the value of system attribute $ChildCount:
$MyNumber = $ChildCount;
In queries and conditional expressions, and attribute reference implies a shortened Boolean test.
The test can be turned in a negative (i.e. that no value is set) by using a '!' prefix: see !$AttributeName, occasionally if the !-prefix does not work, try enclosing the expression in parentheses (!$AttributeName) to help signal intent to Tinderbox's action code parser.
Besides the basic form above, which is essentially
$AttributeName(this), an offset reference can also be made to the value of an attribute in another object— i.e. other than the one in current focus, by using an extended syntax where the scope argument (defining scope) to refer to one or more note(s).
Importantly, here the scope argument is not evaluated for expressions unlike in some action code operators. This means that here, scope cannot be a complex code expression. However, where that need arises eval() may offer a workaround or consider using a user attribute to hold the output of the expression and then use that attribute's value (i.e. in the manner of bullet #4 above).
The extended syntax form may be used on the left or right side of an action code expression. In other words, you can use this syntax to fetch (right side) or set (left side) an attribute value from some other object. Generally, offset references are used on the right side to fetch data from another object.
Examples, right side:
$MyString = $MyString("Some other note");
$MyNumber = $MyNumber("A root container/Some Container/Some other note");
$MyString = $MyString(agent); (this designator only works in agents)
$MyString = $MyString(adornment); (this designator only works in adornments)
$MyList = $MyString("Some other note;Another note;Different note");
$MyString("Another note") = $MyString("A note");
$MyDate(parent) = $MyDate;
In fact an offset can even on be used both sides of the expression. For instance, the rule in a note "Some note" might use the following code to refer to attributes in two other notes:
$MyColor("A note") = $MyColor("Another note");