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
Moving Notes to Containers by Key Attributes (Read 4122 times)
Michael
Full Member
*
Offline



Posts: 4

Moving Notes to Containers by Key Attributes
Jul 11th, 2008, 10:55am
 
Please excuse me if this topic has already been started. I am a newbie and part of the difficulty in being a newbie is not having a vocabulary of sufficient complexity to search topics with any kind of percision.
So here it is...is there a way to craft an action or rule so that when you assign a particular criteria to a note, it will automatically be "moved" into a container meeting that criteria? Like, I have a household inventory with containers representing furniture, applicances, electronics, etc. I would like to give a prototype note "possession" a key attribute entitled "type". When I create a new note representing a particular possession, when I assign a type to the note (e.g. TV = electronics), the note is moved into the appropriate container.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Moving Notes to Containers by Key Attributes
Reply #1 - Jul 11th, 2008, 11:24am
 
The Container attribute will do this. You might use a rule such as:

    if(type="electronics"){Container="/house/electronic devices";}

Another approach -- perhaps more idiomatically Tinderbox, would be to create an Agent that looks for type=electronics.  This doesn't move the original note, which stays where you put it; instead; it makes an alias inside the agent.

The other Tinderbox idiom to consider it reversing the sequence: you move the note into /house/electronic devices, and the container automatically sets "type="electronics".
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Moving Notes to Containers by Key Attributes
Reply #2 - Jul 11th, 2008, 11:51am
 
Ok, we have a string attribute 'Type' and we'll add a Boolean attribute 'Categorised' (name doesn't matter overly and purpose will become clear).

Now make an agent with the query (AgentQuery):
(Prototype="possession")&(!Categorised)&(Type!="")
..and action (AgentAction):
Container=$Type;Categorised=true;

Now, the agent first finds only notes that have the prototype 'possession' and withing that only notes where Categorized is false (we done need to do this task more than once per note!) and within that group notes that have a value for Type. Note how we structure the query so we limit the scope of the quote - not al notes will be possessions so we're note interested in those. Tip - the default value of a Boolean attribute is false (unticked) and note that the true & false values must be written lower case

So, the agent finds the note(s) that need moving. First it sets Container to the desired name, using the Type attribute value from the note being processed. Then it sets Categorised to 'true' thus stopping the agent re-processing this note in subsequent agent cycles.

Assuming you've an Outline view open showing all these notes, you'll see that the process appears on screen as if it takes 2 steps. What's actually happening is that as soon as the agent finds the note and sets the Container, the original note moves but the alias remains in the agent. On the next agent cycle, as Categorised is no longer false, the note no longer matches the agent's query and the alias is removed. Without the Categorised attribute (or whatever name you use) the agent has no choice but to re-run the actions it has already carried out in the previous cycle. As your TBX grows such unneeded repeat actions becomes wasteful though you're not likely to see a dip in performance unless the TBX file gets very large and your agent is processing a lot of notes. Still, it's better to use efficient procedures from the start.

My understanding is that if a value is set for Container and that note doesn't exist, then a new note of that name is created. In my test for this that didn't work (not sure why!). In general i'd advise you set up the containers in advance.

There's more polishing that could be done but that should get you started. Good luck...  

[Mark B's answer beat me to the draw - those suggestions are equally good. In TB there's usually more than one way. By not using an agent you don't need to consider excluding the notes you've already processed to the right container]
Back to top
 
« Last Edit: Jul 12th, 2008, 6:15am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print