Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Agent, Actions, Rules & Automation >> Problem with agent query and set
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1429059349

Message started by Barbara Snyder on Apr 14th, 2015, 8:55pm

Title: Problem with agent query and set
Post by Barbara Snyder on Apr 14th, 2015, 8:55pm

Hi --

I have a user attribute "category" that is a set. I have an agent query:

  $category.icontains("someTerm");

that doesn't work. There are definitely some notes that should match.

  $Name.icontains("someWord") does work as expected.

I also tried

  $category.icontains("someTerm")==true;

because TbRef indicates a boolean return value, but still no luck

How do I make this agent work?

Thanks -- Barbara

Title: Re: Problem with agent query and set
Post by Mark Anderson on Apr 14th, 2015, 9:37pm

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

Bottom line you can't (without kludgy workarounds**) do a partial match for s list or set individual value. You can at best to an exact match for the whole list item value. Slightly counter-intuitively you use list.contains("somevalue") or list.icontains("somevalue") as opposed to list == "somevalue".

** if you really want to: see here.

Title: Re: Problem with agent query and set
Post by Mark Bernstein on Apr 15th, 2015, 11:30am

Barbara Synder: I'm not quite sure I follow you.  I just did the following experiment.

  • $MySet is a set attribute.  In Note A, I make it a key attribute and assign it the value frogs;dogs.

  • I make an agent with the query $MySet.icontains("frogs").

  • The new agent does indeed gather A.




Title: Re: Problem with agent query and set
Post by Barbara Snyder on Apr 15th, 2015, 1:34pm

I was looking for a partial match, eg frog not frogs.

Sent from a small keyboard using big thumbs

Title: Re: Problem with agent query and set
Post by Mark Bernstein on Apr 16th, 2015, 2:55pm

contains() and contains(), when applied to sets and lists, only match complete elements.

If you really do need to search for partial elements, coerce the list or set to a string and use the string version of .contains()

Title: Re: Problem with agent query and set
Post by Mark Anderson on Apr 19th, 2015, 3:25am

For details on doing the latter in MB's post, see the last link in my previous post.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.