Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Moving to Tinderbox 6 >> Using agent $Name as part of it's Query
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1438615681

Message started by BCrane on Aug 3rd, 2015, 11:28am

Title: Using agent $Name as part of it's Query
Post by BCrane on 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!

Title: Re: Using agent $Name as part of it's Query
Post by Mark Bernstein on 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))

Title: Re: Using agent $Name as part of it's Query
Post by BCrane on 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.

Title: Re: Using agent $Name as part of it's Query
Post by J Fallows on 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.

Title: Re: Using agent $Name as part of it's Query
Post by Mark Anderson on 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.

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.