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 >> Gah! Agent queries are melting my brain!
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1206312282

Message started by Rafter T. Sass on Mar 23rd, 2008, 6:44pm

Title: Gah! Agent queries are melting my brain!
Post by Rafter T. Sass on Mar 23rd, 2008, 6:44pm

Whoops, sorry. That just slipped out.

I'm (trying to commence) using agents to sort notes representing plant species, for an ecological landscaping project.

I have a user attribute called Light, defined as a set.
I've used an adornment-based workflow to assign the values "FullSun" , "PartShade" , and/or "FullShade" to this attribute.

Now, for reasons I cannot discern, I can't formulate an agent query that picks this out.

I've tried a dozen or so permutations, with more and less $s,"s, and ()s:

$Light(FullShade) | $Light(PartShade)
   
-picks out nothing.

$Light(FullShade)

-picks out every note in the document, apparently, including ones with no value assigned to Light

Light(FullShade)  ...and... Light("FullShade";)  ...and... $Light="FullShade"

-all pick out nothing, despite the fact that there are dozens of notes wherein Light contains "FullShade"

What am I missing here?

Just to flesh it out a little...

It appears that the contents of every attribute I've defined as a set are invisible to agents as well as to Find Text. There are 1 or 2 inscrutable exceptions, such as the single plant that will be returned by the query Moisture(Wet); out of dozens of plants w/ that character.

If the set attribute is named with the $ in front, the query returns ALL the notes in the document.

All attributes have been set by adornment actions, so set contents are standardized.

I'm completely at a loss.  



Title: Re: Gah! Agent queries are melting my brain!
Post by Mark Anderson on Mar 24th, 2008, 6:51am

Using $ with attribute names is incorrect for agent queries (but not OnAdd Actions) as in the context of a query a '$' character implies the reqular expression meaning of an end of line marker.

Following your description I made a new (TB v4.2.2) TBX and added a set attribute called  'Light'. I then added 2 notes with the follwing Light values:
- Hellibore (Light = PartShade;FullShade;)
- Daffodil (Light = FullSun;)

An agent with the query Light(FullShade) correctly finds just the 'Hellibore' note. Note the semi-colons in a note's value lists for a set attribute are delimiters and not used in searching for values.

As you tried and failed using the correct agent query I suspect other factors are at play.  Either the the attribute values aren't stored as you test for them (e.g. Full Sun, vs FullSun) or you've other factors in the agent query.  If the latter try deconstructing the query. Test each part on its own so you know it works. Then start building them together so when (if!) the query doesn't work you've a better idea as to what aspect isn't working.

Title: Re: Gah! Agent queries are melting my brain!
Post by Rafter T. Sass on Mar 24th, 2008, 3:51pm

OK! Thanks so much for your help.

I found the syntax that worked: Light("FullShade")
In trying to work my way through all permutations, I had tried Light("FullShade";) - now with free extraneous semicolon - but not the above. My goodness, I thought I was going to loose it.

So - next question:
I see now that I set up my adornments to add values in "double quotes" because I thought it was necessary. Instead it now appears as inelegant extra characters in my set values.
How could I get an agent to remove those double quotes, without 'manually' scripting replacement of each specific "String" in each set, with String ?

There is no emoticon to express my appreciation.







Title: Re: Gah! Agent queries are melting my brain!
Post by Mark Bernstein on Mar 24th, 2008, 4:38pm

Suppose your set attribute is Light.

Query:  Light("FullShade")  

will collect all the notes with in which Light contains the value, "FullShade"



Action:  Light=$Light+"FullShade"

will add the value FullShade (without quotes) to Light.  

I'm not quite sure I understand how you got the double-quoted values into the set.  I think the easiest way to remove them might be to edit the XML; but I bet a clever user will come up with an elegant answer shortly.

Title: Re: Gah! Agent queries are melting my brain!
Post by Rafter T. Sass on Mar 24th, 2008, 5:41pm

Somehow or other, values are getting in there with quotes:

The syntax:
Habitat=+"OpenWoods"
is producing set values structured like this:
Habitat | "OpenWoods";"Forest";"Other"

I'm interested in figuring out how to get all those quotes out, and I'm interested in figuring out how it happened.

Any ideas?

Title: Re: Gah! Agent queries are melting my brain!
Post by Amber Vaesca on Mar 24th, 2008, 6:06pm

Edited out---Saw there was a better way already.

Oh, and by the way I always do set assignments like:

Code:
Set="+value one"

Then you don't get quotes in your values.

Title: Re: Gah! Agent queries are melting my brain!
Post by Mark Anderson on Mar 24th, 2008, 6:33pm

Following along in the margins, I was confused as to how the double quotes got into the actual set values. By experimentation:
Bad:
Light=+"FullShade"
...adds a set value of '"FullShade"'
Good: any of
Light=$Light+"FullShade"
Light=+FullShade
Light="+FullShade"
...adds a set value of 'FullShade'

I suspect this is an unexpected consequence of some under-the-hood parsing of inputs. For the new/less experienced TB user I'd suggest assuming it to be a syntax rule that you use the
AttributeName=$AttributeName+"The value"
form to add to a set and
AttributeName=$AttributeName-"The value"
form to remove a set. The fact there are alternate short syntax styles doesn't help the newer user given the sort of unintended errors you can make (as described in the thread above). In general, from v4.x onwards we're encouraged to move towards quoting string literals in Rules and actions (but not Queries) so the last example above works, is explicit as to purpose and compliant with quote-enclosing strings (e.g. adding 'Full Sun' vs. 'FullSun').

Title: Re: Gah! Agent queries are melting my brain!
Post by Rafter T. Sass on Mar 24th, 2008, 10:11pm


Amber Vaesca wrote:
Edited out---Saw there was a better way already.



Mmm - what was that better way exactly?

It swear I saw a post from one of the Marks earlier today, with an "inelegant" (his words) but functional approach to automating weeding out the superfluous doublequotes. Which way did it go?

Thanks so much, again, again.



Title: Re: Gah! Agent queries are melting my brain!
Post by Amber Vaesca on Mar 25th, 2008, 3:22am

Trust me, it was magnitudes more inelegant. :) I didn't realise that re-assignment would be recognised as the same value---just without quotes.

Title: Re: Gah! Agent queries are melting my brain!
Post by Mark Bernstein on Mar 25th, 2008, 10:06am

To add a value to a set, the base syntax is:

      TheSet = $TheSet + "value"     <-- GOOD

This might be abbreviated thus:

    TheSet = "+value"                    <-- GOOD

I would usually avoid the abbreviation, but it's useful in stamps and also when space is at a premium.  Tinderbox currently supplies missing quotation marks in many cases, so you can get away with this:

    TheSet = +value                      <-- DEPRECATED

I'd try to avoid this form, because it might not work forever.

Title: Re: Gah! Agent queries are melting my brain!
Post by Mark Anderson on Mar 25th, 2008, 12:36pm

Pending the opportunity to update the manual which is - unintentionally - a little ambiguous on the use of quoted strings in sets, I've updated this page on aTbRef.

This area of quoting-or-not is a bit of a no-win scenario for the manual's author. Make too many syntax 'rules' and some of Tinderbox's power and flexibility may be hidden from users who are experienced coders. Conversely, an "anything goes" approach is used - especially when some syntaxes don't 'go' - and it can hamper the newer user trying to get started.  

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.