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
[Frustrated] Query to find siblings (Read 2874 times)
manuelkuhs
Full Member
*
Offline



Posts: 21

[Frustrated] Query to find siblings
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.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: [Frustrated] Query to find siblings
Reply #1 - 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

Back to top
 
 
WWW   IP Logged
manuelkuhs
Full Member
*
Offline



Posts: 21

Re: [Frustrated] Query to find siblings
Reply #2 - 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!
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: [Frustrated] Query to find siblings
Reply #3 - 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.
Back to top
 
« Last Edit: Nov 25th, 2014, 4:01am by Mark Anderson »  

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



Posts: 21

Re: [Frustrated] Query to find siblings
Reply #4 - 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?
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: [Frustrated] Query to find siblings
Reply #5 - 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.
Back to top
 
 
WWW   IP Logged
manuelkuhs
Full Member
*
Offline



Posts: 21

Re: [Frustrated] Query to find siblings
Reply #6 - Nov 25th, 2014, 3:45pm
 
I've been referring to atbref constantly Smiley

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.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print