This version is out of date, covering development as far as v4.2.5. It is maintained here only for inbound reference links from elsewhere. Jump to the current version of aTbRef. |
A Tinderbox Reference File : Agent Queries : Attribute Name |
Attribute Name |
In v2.4.0 onwards String [sic] attribute names may be used for queries:
The target attribute need not always be specifically of String type. For instance, a File type attribute holds a path to a file - which is a string - and can thus be queries in the above fashion.
Note text can be searched too, as the Text attribute represents the note's body text.
In v3.0.0 is added a simple AttributeName query method that gathers notes for which the boolean value of AttributeName (of any date type [sic]) evaluates to true. For numeric attributes, true is any value other than zero. For string attributes, true is any value other than "false" and the empty string. For date attributes, true is assumed to be a matching day. This query type may also be used in export templates. For example: ^any(child,Urgent)^ gathers all notes which have at least one child whose Urgent attribute resolves to true.
StringAttribute( data or pattern )
Gathers all notes whose AttributeAttribute contains the data string or matches the pattern regular expression.
Patterns, i.e. regular expressions, are those defined for Boost (http://www.boost.org/doc/libs/1_34_1/libs/regex/doc/syntax_perl.html).
For a negative match, where the string is not matched, use an alternate syntax with a preceding exclamation mark (!):
!StringAttribute( data or pattern )
Note how the '!' that triggers the match reversal is placed before the attribute name and not the (data or pattern) part. Thus, opposing examples:
Text(smith)
!Text(smith)
The above two example would have no overlap in their matches.
SetAttribute( data or pattern )
Gathers all notes whose SetAttribute values match the data string or matches the pattern regular expression. Unlike a string attribute value where partial matches can be made, the match here must be for a complete individual set value.
Thus for an Set called MySet with three values 'Carpet;Carrot;Car;', a query for MySet(Ca) would return no matches. This is because the string 'Ca' is not a complete match for any of the values. MySet(Car) would get 1 match only - 'Car'. Despite both other values containing the sub-string 'Car', there is no match.
Otherwise the observations above re patterns and negative searches apply.
Comparison Operators
Note that the = operator always works as a case-sensitive comparison. To match all case variants of 'dog' (dog, Dog, DOG, etc.) use a contains match, MyAttr(dog). As this would also find a value 'big dog' the match can be further restricted by regular expression string delimiters, e.g. MyAttr(^^dog$). The ^ forces matching to start at the beginning of the string; doubling the ^ tells Tinderbox the symbol is not Tinderbox mark-up code. Similarly, the $ forces the match to run all the way to the end of a value. This excludes longer strings that might contain the word in question. The use of the $ in a regular expression should not be confused with the $AttributeName usage.
From v3.6.0, the agent queries >, >=, <, and <= now allow a new form
Name > $attribName
or
attribName > $attribName(path)
This allows queries such as
Created>$Created(parent)
Name<$Text
BorderColor=Color
$Attribute notation
From v3.6.0, more flexible agent queries are now supported. In addition to the conventional queries
AttributeName=value
and the newly-supported
AttributeName=$AttributeName
AttributeName=$AttributeName(where)
Tinderbox also allows '$'-notation in the left-hand side of queries
$AttributeName=AttributeName(where)
$AttributeName(where)=$AttributeName(where)
Notice that either/both the left or right-hand expressions must begin with a '$'. Do not mix $Attribute and Attribute(pattern) syntax in a single statements, i.e. $Attribute(pattern), as this will cause expected results.
The query syntax
$AttributeName(pattern)
means the value of attribute $AttributeName contains the string 'pattern'.
Examples:
$Name(parent)=archives
$ChildCount(parent)>6
Up: Agent Queries | |
Previous: Basic Comparison Operators | Next: Template Code Arguments |
Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
[See aTbRef CC licence Attribution/Waiver info info]