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
Using agent $Name as part of it's Query (Read 2379 times)
BCrane
Full Member
*
Offline



Posts: 22

Using agent $Name as part of it's Query
Aug 3rd, 2015, 11:28am
 
In a large TBX file I have a series of agents that each collect notes based on the query of a single $Tags attribute, mostly author names. So for example, I might have an agent with the $Name "Yukio Mishima" that queries:

         $Tags.contains("Yukio Mishima")

Easy. But after making a few of these, I've realized I would like, if possible, to simply name the agent and have a prototype set the query, but I'm stumped.

What I've done is create prototype called "p_Tag_agent" and adapted an example from the old version of the TBref to write this rule:

         if(!$IsPrototype){$AgentQuery=$Tags.contains($Name)}

Unfortunately this doesn't work and so I've got two questions:

1. If I put the query "Tags.contains($Name)" in its own agent, that agent works and returns results. So something is wrong with the other bits but I have no idea what it is. Is there a difference between how this is done in v.5 and v.6? Does my prototype have to be an agent as well?

2. Based on what my test agent does, "Tags.contains($Name)" isn't doing what I want it to. It is looking at notes and asking "does this note have its own name as a tag?" I want the agent to ask "does this note have MY name as a tag?" So I have to get the agent to pull it's own name, not the note's name. But the agent won't be a parent or child of the notes is searching for. So I've got no clue what to do.

Any thoughts or ideas would be welcome!
Back to top
 
« Last Edit: Aug 03rd, 2015, 11:30am by BCrane »  
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Using agent $Name as part of it's Query
Reply #1 - Aug 3rd, 2015, 12:29pm
 
In agent queries, this is bound to the note being examined, so $Name represents the name of the note being examined. The name of the agent is $Name(agent).

    $Name.contains($Name(agent))
Back to top
 
« Last Edit: Aug 3rd, 2015, 12:29pm by Mark Bernstein »  
WWW   IP Logged
BCrane
Full Member
*
Offline



Posts: 22

Re: Using agent $Name as part of it's Query
Reply #2 - Aug 3rd, 2015, 1:08pm
 
Thank you!

What I set up is a prototype ("p_tag_agent") that adds automatically when I create notes in the tag agent folder. Then in my main agent folder, I made a separate agent that searches for $Prototype=("p_tag_agent") and has the action $AgentQuery="$Tags.contains($Name(agent))".

It works and makes more sense to me then what I was trying to do with the prototype.
Back to top
 
 
  IP Logged
J Fallows
Full Member
*
Offline



Posts: 418

Re: Using agent $Name as part of it's Query
Reply #3 - Aug 6th, 2015, 10:32am
 
This is an example of an obvious-once-it's-explained aspect of Tinderbox that I hadn't actually thought through before.

Setting up an agent prototype, with a standard query of $Name.contains($Name(agent)), really streamlines something I do fairly often. It hadn't occurred to me to set the query to look for $Name(agent), so thanks for asking this question "in public" so that we can all see the answer.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using agent $Name as part of it's Query
Reply #4 - Aug 6th, 2015, 1:39pm
 
If making a prototype agent, you might want to use the query:

$IsPrototype==false & $Name.contains($Name(agent))

This is like setting $RuleDisabled for a prototype but for queries. As the prototype's query fails the first test, it can be left 'on' save in the knowledge it won't match anything. Assumption: not of the notes we do want to match are themselves prototypes for other reasons.
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