Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Gah! Agent queries are melting my brain! (Read 11533 times)
Rafter T. Sass
Full Member
*
Offline



Posts: 100
Burlington, VT
Gah! Agent queries are melting my brain!
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.  


Back to top
 
« Last Edit: Mar 23rd, 2008, 11:13pm by Rafter T. Sass »  
raughter   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Gah! Agent queries are melting my brain!
Reply #1 - 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.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rafter T. Sass
Full Member
*
Offline



Posts: 100
Burlington, VT
Re: Gah! Agent queries are melting my brain!
Reply #2 - 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.






Back to top
 
 
raughter   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Gah! Agent queries are melting my brain!
Reply #3 - 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.
Back to top
 
 
WWW   IP Logged
Rafter T. Sass
Full Member
*
Offline



Posts: 100
Burlington, VT
Re: Gah! Agent queries are melting my brain!
Reply #4 - 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?
Back to top
 
 
raughter   IP Logged
Ioa Petra-ka
Full Member
*
Offline



Posts: 103
Portland, Oregon, USA
Re: Gah! Agent queries are melting my brain!
Reply #5 - 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.
Back to top
 
« Last Edit: Mar 24th, 2008, 6:24pm by Ioa Petra-ka »  

Av
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Gah! Agent queries are melting my brain!
Reply #6 - 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').
Back to top
 
« Last Edit: Mar 24th, 2008, 6:35pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rafter T. Sass
Full Member
*
Offline



Posts: 100
Burlington, VT
Re: Gah! Agent queries are melting my brain!
Reply #7 - Mar 24th, 2008, 10:11pm
 
Amber Vaesca wrote on Mar 24th, 2008, 6:06pm:
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.


Back to top
 
 
raughter   IP Logged
Ioa Petra-ka
Full Member
*
Offline



Posts: 103
Portland, Oregon, USA
Re: Gah! Agent queries are melting my brain!
Reply #8 - Mar 25th, 2008, 3:22am
 
Trust me, it was magnitudes more inelegant. Smiley I didn't realise that re-assignment would be recognised as the same value---just without quotes.
Back to top
 
 

Av
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Gah! Agent queries are melting my brain!
Reply #9 - 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.
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Gah! Agent queries are melting my brain!
Reply #10 - 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.  
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print