= (assignment)

Tinderbox Icon


Operator Type:   Operator
Operator Scope of Action:   Item
Operator Purpose:   Assignment

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:

$AttribName(parent)="theValue" 

$AttribName(/path/to/note)="theValue" 

$AttribName(/path/to/note)=$MyValue(parent) 

$AttribName($AnotherAttribute)="theValue" 

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.

If a value only needs to be assigned once, consider using a logical OR join.

Using Paths (offset references)

$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:

query: Text(email: <(.+)>)

action: $TheAddress=$1

...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.


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

Up: Assignment operators

A Tinderbox Reference File : Actions & Rules : Operators : Action Operator Types : Assignment operators : = (assignment)

Quicklinks: Attributes | Action Codes | Export Codes | Designators | Date Formats | aTbRef Site Map

[Last updated: 16 May 2012, using v5.11.1]


Search:

Google search aTbRef for:  


Creative Commons Licence

aTbRef by Mark Anderson is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

[See aTbRef CC licence Attribution & Waiver info]

Made with Tinderbox