This version is out of date, covering development from v4.6.0 to v4.7.1. It is maintained here only for inbound reference links from elsewhere.
Jump to the current version of aTbRef.
|A Tinderbox Reference File : Actions & Rules : Operators : Action Operator Scope : Item-based operators : = (assignment)||aTbRef Site Map|
|Operator Scope of Action:||Item|
In post v4.6 syntax, the = symbol is only used as a method of assignment:
$AttributeA = $AttributeB
$AttributeA = data
The assignment is always from right to left; the left-side attribute takes the value of the right side attribute/expression. It is more usual for the right side to be evaluated (an expression) than the left, though the latter can occur.
Thus assignment sets the value of the specified Attribute to the given data; most often this is an attribute value. However, note that the data is a fixed value, not an expression. If a string to right of an = sign (or any variant of that, !=, <=, etc.) is a $-prefixed attribute name, the name and not the value of the attribute is assigned as the value of the left side's attribute. Assume a note has a Color value of 'red' and the Rule:
$MyUserAttr = "Color"
The result is not the text value 'red' but rather it is a text value 'Color'. If you want the value of an attribute, i.e. 'red' in this example, then your rule should be:
$MyUserAttr = $Color
You must use the $ prefix - see further detail below.
Actions and rules are allowed to specify a different target note, just as they can with a source attribute reference:
In the last case the secondary attribute will hold a note name or path.
Do not mix $Attribute and Attribute(pattern) syntax in a single call, i.e. $Attribute(pattern), as this will cause expected results. Use one syntax or the other. This possible conflict should only ever occur in the context of queries or operations that allow query-style code.
Pre v4.6, it was possible to confuse use of the = sign in actions and rules with that in agent queries. In the older versions an = in queries used to imply a comparison, though now the == syntax is used for that purpose. With actions/rules a single = is always an assignment.]
Pre v4.6 the use of ^get^ and ^getFor^ in actions and rules was allowed but is deprecated in favour of the $ syntax. $Attribute(note) is the analogue of ^get(Attribute)^, whilst $Attribute(note) is the analogue of ^getFor( note, Attribute )^.]
$AttributeA = $AttributeB( note/item/path )
This sets the value of the $AttributeA to that of the $AttributeB of the same note (i.e. this or current), if no argument is specified, or of a note specified through name, item or path. (See more on paths). From v4.6, paths may also be used on the left side of the overall expression:
$AttributeA( note/item/path ) = $AttributeB
$AttributeA( note/item/path ) = $AttributeB( note/item/path )
Using query back-references
NOTE: the following syntax can only be used in the context of a query. In a query it is possible to combine a pattern query with an action that uses the value of the found pattern:
...will set TheAddress attribute value to the pattern found in text. It is assumed that back-references $1-$9 may be used, assuming the pattern generates more than one such references.
|Up: Item-based operators|
|Previous: / (division)||Next: == (equality)|
Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
[See aTbRef CC licence Attribution/Waiver info info]