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 >> [Frustrated] Query to find siblings
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1416839954

Message started by manuelkuhs on Nov 24th, 2014, 9:39am

Title: [Frustrated] Query to find siblings
Post by manuelkuhs on Nov 24th, 2014, 9:39am

I'm a complete noob to Tbx. However, I have lots of general computer experience, basic programming experience, and usually learn tech stuff pretty quickly. But some things that I thought would be simple in Tbx have me stumped (after several hours of playing with it, browsing Help and aTbRef).

Inside a container I have an agent. I want the agent to find (or rather, limit the next query to) all its siblings, i.e. all notes that are children of the agent's parent.

The query "parent" finds all notes I've created??? I don't understand this result at all...
The query "contains(agent)" successfully gives me the agent's parent (is there a better way to get this?)

Moving to the next step, the query 'child(contains(agent))' finds nothing.

I'd appreciate some basic explanation of how this works. The potential of Tbx has me excited, but it's frustrating not being able to do what seems simple to me.

Title: Re: [Frustrated] Query to find siblings
Post by Mark Bernstein on Nov 24th, 2014, 10:00am

Let's suppose CONTAINER holds AGENT and some other notes -- TURKEY, CRANBERRIES, PIE.  TURKEY and PIE have $IsHot true, but CRANBERRIES are not hot.

The Agent query might be

    $Name(parent)=="CONTAINER" & $IsHot==true

Or, if there might be several notes with the name CONTAINER,

   $Path(parent)=="/path/to/CONTAINER" & $IsHot==true

Or, more concisely and more efficiently

     inside(/CONTAINER) & $IsHot ==true


Title: Re: [Frustrated] Query to find siblings
Post by manuelkuhs on Nov 24th, 2014, 10:21am

Hi Mark,

Thanks for the fast answer.

That works. I have adapted it to:

Code:
inside(parent(agent))

because I want to duplicate this agent in several different containers and thus don't want to manually specify CONTAINER

Thanks Mark!

Title: Re: [Frustrated] Query to find siblings
Post by Mark Anderson on Nov 24th, 2014, 1:03pm

To also answer the original questions:


Quote:
The query 'parent' finds all notes I've created??? I don't understand this result at all…

The query 'contains(agent)' successfully gives me the agent's parent (is there a better way to get this?)

Moving to the next step, the query 'child(contains(agent))' finds nothing.


If the whole of the query really is just parent, then you're actually effectively asking, via the value of each note's parent designator, if each note in the document has a parent. They all do; even root-level notes are children of the document itself. As all notes in the doc have a parent, coercing the "parent" test to a boolean true/false result, the test is true for all notes which are thus added to the agent. Footnote, don't test bare designators or note names in this fashion: use $Name(original(parent))=="something" or $Name(original(parent))==$Name(agent(parent)) or suchlike.

The query contains(agent) is also an ambiguous query. The agent designator implies a reference to the agent object but contains($Name(agent)) or contains($Path(agent)) would be better and more self-explanatory expressions of this. Anyway, you are testing for a note that is the container of the agent which, as you should expect returns a single item - the agent's parent (i.e. container) note.

Using child(contains(agent)), you appear to be trying to ask each note in the doc contains the agent, but the syntax is incorrect. Using an offset reference normally involves citing a relevant attribute. Also, designators can nest other designators, e.g. original(parent), the nesting being parsed in left to right order (i.e. as read). Designators may also use a nested find() though ideally the query in the find() should not be overly complex. I think in this case you meant to ask child(find(contains(agent))) although that still wouldn't really make sense for the reasons stated.

Title: Re: [Frustrated] Query to find siblings
Post by manuelkuhs on Nov 25th, 2014, 8:11am

Thanks for all your answers!

Don't fully understand them all, but I'm working hard to get there...

Is there a tutorial I can watch/work through to teach me proper logic/syntax of expressions, actions, rules, agents?

Title: Re: [Frustrated] Query to find siblings
Post by Mark Bernstein on Nov 25th, 2014, 12:07pm

For a reference on actions, see aTbRef: http://www.acrobatfaq.com/atbref5/

I'm working on a new agent tutorial document.

Title: Re: [Frustrated] Query to find siblings
Post by manuelkuhs on Nov 25th, 2014, 3:45pm

I've been referring to atbref constantly :)

Can't wait for the agent tutorial, awesome!

I'm making slow but steady progress (spending around 6 hours per day on it). Definitely a steep learning curve - but I'm excited about what's possible.

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.