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
how to automate a text-finding agent (Read 1874 times)
Gregg Williams
Full Member
*
Offline



Posts: 23
San Jose CA
how to automate a text-finding agent
Nov 09th, 2016, 11:39pm
 
In my TBX document, a top-level container named "Items" contains, of course, multiple notes.

If I want to create an agent that finds all the notes inside Items that contain, say, "todo", I simply create an agent note that has

    $AgentQuery = "(inside(items)) & $Name.contains("todo");"

Fair enough.

Now here is what I want to do:

* create a new agent and name it "pending"
* set the prototype of this agent to, say, "protoNameTextAgent"

What I would like to do is have this agent named "pending" automatically find all the notes inside "items" that contain the word "pending" (i.e., the same text as the $Name of the agent itself). This way I can quickly create agents that find notes that have a given word in them.

- - -

I've confirmed that such an agent works when

    $AgentQuery = "(inside(items)) & $Name.contains($Name(agent));"

However, I haven't figured out how to make this happen through the mechanism of assigning a prototype to a new agent. I'm open to other ways to create the same result without having to do everything manually.

Any ideas? Thanks!
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: how to automate a text-finding agent
Reply #1 - Nov 10th, 2016, 4:50am
 
Your agent query should be:

inside("Items") & $Name.contains("todo")

You don't need the extra parentheses around the inside() operator. Also, 'Items' is a note name and so should be enclosed in quotes (by convention, only designator strings like 'parent' or 'agent' aren't quoted, but still work if quoted). Note names are case sensitive so an inside() call for "items" will not match notes in "Items".

To set that via an action, place the whole action in quotes. As double quotes are already used, use the single quotes for this:

$AgentAction = 'inside("Items") & $Name.contains("todo")';

But, you don't need to do the latter. Make a prototype note [sic] with the name 'protoNameTextAgent'. Use Get Info or Quickstamp to set the note's $AgentQuery. Althuogh note's don't make use of attributes in the 'Agent' group, they may still have values assigned - for scenarios just like this one here. IF using Get Info, don't use the 'agent' sub tab as only actual agents have that active, you must use the 'attributes' sub-tab and then select the 'Agent' group. The value to paste into $AgentQuery is:

inside("Items") & $Name.contains($Name(agent))

No outer quotes needed as were setting the value directly into the attribute rather than by an action.

Now, to use the prototype, make a new agent and immediately close the pop-over that opens. Rename the agent to the desired search term and set the agent to use the protoNameTextAgent prototype.

If you want you can make a container with the $OnAdd:

$Prototype = "protoNameTextAgent";

This will automate the last step above for you for any new agents you make in that container.
Back to top
 
 

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



Posts: 23
San Jose CA
Re: how to automate a text-finding agent
Reply #2 - Nov 16th, 2016, 11:44pm
 
Mark, many thanks for your excellent and thorough response. Your info saved the day! GW
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: how to automate a text-finding agent
Reply #3 - Nov 17th, 2016, 6:09am
 
Glad to hear it.  Thanks for the feedback - I think it can be useful for later readers to know if suggestions have actually helped.
Back to top
 
 

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



Posts: 418

Re: how to automate a text-finding agent
Reply #4 - Dec 23rd, 2016, 9:57am
 
Chiming in a month later to say to Mark A: Yes, thanks for this obvious-once-it's-pointed-out code. Very handy! And thanks to Gregg W for asking.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: how to automate a text-finding agent
Reply #5 - Dec 23rd, 2016, 11:16am
 
If you find yourself wanting to do this, or something like it, take a moment to think about Attribute Browser.  

That won't suffice in this specific case, but it would if you "todo" and "pending" were $Tags rather than found in the text.  And extracting tags from text is not hard to do, either:

     Query: $Text.contains("todo")
     Action: $Tags = $Tags + "todo"

Back to top
 
 
WWW   IP Logged
J Fallows
Full Member
*
Offline



Posts: 418

Re: how to automate a text-finding agent
Reply #6 - Dec 23rd, 2016, 10:54pm
 
Quote:
take a moment to think about Attribute Browser


Yes, 100% agree and was going to add this (but obviously didn't). It's a TB feature I use every day.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print