Querying Lists and Sets

Tinderbox Icon

Testing (querying) lists and sets

Testing lists/sets, the contains operator, syntax AttributeName.contains("pattern"), returns true if a list/set contains an exact match for the the designated pattern; the test is case sensitive regardless of agent query case sensitivity settings; regex matches are not supported. If user attribute PetTypes has a value of "dogs;cats" then either

$PetTypes.contains("dogs") is true,

but

$PetTypes.contains("dog") is false

as 'dog' is an incomplete value match.

It can be useful to use a stored value as the search pattern, for instance using the name of an agent as the search term. However, the following won't work or an agent named 'dogs':

$PetTypes.contains($Name) WRONG!

Instead, use the evaluated result of the above via a rule or some other action code. Thus, in an agent's Rule box, enter:

$AgentQuery='$PetTypes.contains("'+$Name+'")' 

…which results in a query of:

$PetTypes.contains("dogs") 

See Set Attributes for more on Sets.


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

Up: Agent Queries
Previous: String Attributes - comparison operators & case sensitivity  Next: Query for descendants of matched notes 

A Tinderbox Reference File : Agent Queries : Querying Lists and Sets

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