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 2 
Send Topic Print
agent to move note, not create alias (Read 14592 times)
Graham Smith
Full Member
*
Offline



Posts: 66
Somerset, UK.
agent to move note, not create alias
Dec 20th, 2012, 6:17pm
 
I have an agent set up for each month that gathers notes from a master list of tasks, depending on a month attribute (called when) in the note. I have a  query that looks like this $When="January" in the agent.

But this creates an alias, and I want to remove the note from the master list once it has been collected by the agent.

I have tried adding an action original="/January", but this creates a new container called January with the moved note, as well the alias under the action.

I don't want an alias anywhere, i just want the original note moved into a container called January. Can I set up a rule in a container that will do this, without using an agent.

I also want to still be able to change the "when" attribute to a different month and get it moved from January to say May.

I would appreciate some help, thanks,

Graham
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: agent to move note, not create alias
Reply #1 - Dec 20th, 2012, 6:57pm
 
To move the original of an alias in an agent, set the $Container attribute of the aliases' original, i.e. $Container(original), to the desired value (i.e. the path to the new container of the original).
Back to top
 
 

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



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #2 - Dec 20th, 2012, 6:57pm
 
To reply to myself, I seem to have solved this but if what I have done can be improved I would appreciate any advice.

I now have a rule

$MyCount = sum(children,$TimeRequired);$When="February", original="/February"

Obviously the sum script is doing something else.

Graham
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: agent to move note, not create alias
Reply #3 - Dec 20th, 2012, 7:11pm
 
OK, I think your rule should be:

$MyCount = sum(children,$TimeRequired);$When="February";$Container(original)="/February";

If the code in your last post above works I think it's by lucky chance (good guess by Tinderbox!).
Back to top
 
 

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



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #4 - Dec 20th, 2012, 7:14pm
 
In fact I haven't, it moves the note from the master list, but once its moved to the initial month container, it doesn't move if I then change the month.  Sad

Graham
Back to top
 
 
  IP Logged
Graham Smith
Full Member
*
Offline



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #5 - Dec 20th, 2012, 7:18pm
 
Thanks Mark, I have modified as you suggest, but the problem I mentioned above persists and I can't move the note a second time, e.g from January to February.

Graham
Back to top
 
 
  IP Logged
Graham Smith
Full Member
*
Offline



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #6 - Dec 20th, 2012, 7:24pm
 
Actually, now that I have removed the agents, this isn't working at all, neither my original code or your suggested code!

Graham
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: agent to move note, not create alias
Reply #7 - Dec 20th, 2012, 7:35pm
 
I'm unclear exactly what's needed. From reply #5, it looks like a note's $When attribute and you want the original to be placed in that container whose $Name matches when?

How about a rule in the note:

if($Name(parent) != $When) {$Container==$When}
Back to top
 
 

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



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #8 - Dec 21st, 2012, 1:16am
 
Mark, thanks for the persistence, but that code, when I add it to my existing February container is giving me a new container called =$When, with my original February container inside this new one. Maybe we need to go back to scratch

My outline is

Master
Today
This week
This Month
January
February
March
etc

I have a prototype for the Master list that has an attribute called "when" which defaults to master.

The idea is that when I review the master list, I can change the when attribute to  "today" or  "This week", or "This month", or to some future month "January" or "February" etc.

Once the master list has been reviewed and tasks placed in an appropriate container, I can then subsequently review the containers and move tasks between containers by changing the when attribute.

And to round off the rationale (but not part of the problem), the "sum" part of the script adds up the time required for all the tasks within a container and displays it.  This means I can quickly identify that I have 15 days worth of work allocated in January, 9 in February, 20 in March, 5 in April etc.  So if I get asked to do 15 days worth of work, I know I can't do  it until April, or at least not without juggling other work around.

It was all working fine, except for the problem that the agent produce an alias, and left the original in the master list.  I want the master list to empty as I allocate tasks a time/month container.

Graham
Back to top
 
 
  IP Logged
Graham Smith
Full Member
*
Offline



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #9 - Dec 21st, 2012, 1:44am
 
I seem to now be back to where I started.

I have an agent with:

Name: February
Display expression: $Name + "  (Total Time = " + $MyCount + ")"
Query: $When="February";
Action: $Container(original)="/February";
Rule: $MyCount = sum(children,$TimeRequired);

This is using the agent as a container that is being populated with aliases.  

So hopefully, I just need to know how I tweak this so I move the note where When = February rather than creating an alias of it.

Thanks,

Graham
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: agent to move note, not create alias
Reply #10 - Dec 21st, 2012, 6:09am
 
Well the agent works, as I'd expect, though note that the query really should use == rather than = for the comparison (see more). Also, queries don't use semi-colon terminators (happily, I think Tinderbox just ignores them!). So let's restate the query as:

Query: $When=="February"

Henceforth, I'll assuming you're using the latter. I think I see that confusion now. The agent is doing what's required. The agent is moving the original but the agent is still showing aliases. This is to be expected as your query looks for all notes (and indeed aliases) where the $When attribute has the value "February". Of course, even after the original has moved container, $When still has a value and thus matches the agent and thus the existence of the aliases that you intuit should not exist. Let's fix thatů

There are two possible approaches. First, we could delete the $When value on moving the original. Thus the action would become:

Action: $Container(original)="/February";$When="";

The extra bit of code sets $When to an empty value. I'd normally reset to default (e.g. $When=;) but you say you set a default value which might then cause some unintended action in another agent. If you wish you could set a value such as "Done". As ever, there's no one right way and of course your agent will only show a time count of zero as you've no aliases! We'll fix that in a moment but let's look at the other querying approach...

Exclude the moved notes from this agents search. What? Well if we do that after the move the note will no longer match the February agent and no alias will appear in the agent, as you want. Also, if you realise you've made a mistake and set $When in the moved note to "March", the March agent will find it and move it (as we never make mistakes setting data <g>). To do this change the query to:

Query: $When=="February" & !inside("February")

As before the first part finds all the February notes but now the second part strips outside those inside (i.e. children of) the container "February". note that the alias will exist until the next agent update cycle after the original is moved.  IOW, from a user standpoint, there appears to be a short delay between the original moving and its original agent alias disappearing.

Now to fix the time count issue. To do this we need to count only the notes inside the "February" container:

Rule: $MyCount = sum(children("/February")),$TimeRequired);

To make it easier to make agent for other months, set the desired month/whatever 'When' value in the agent's $When and use these settings:

Name: [whatever]
Display expression: $Name + "  (Total Time = " + $MyCount + ")"
Query: $When & !$AgentQuery & $When==$When(agent) & !inside($When(agent))
Action: $Container(original)=$When(agent);
Rule: $MyCount = sum(children($When(agent)),$TimeRequired);
When: [the desired $When value to be tested]

OK, the query grew a bit. Why? OK the first test ensure we only match notes with a $When value. Otherwise as <blush> I discovered in testing, all the notes with no $When get note to a container "", i.e. the outline root - oops!  So, having avoided that we also want to stop the agent itself being moved (as it too has the $When value we're testing for). Then the query is as before.

So now, having made and tested the latter agent you can make a copy, change $Name and $When values and you've just made the agent for a different month.

The additional query shows why its worth using things like prottypes to find only a subset of notes. Let's say all your notes of interest, and only those notes, use a prototype "pTask". We can then write the last query more cleanly:

Query: $Prototype=="pTask" & $When==$When(agent) & !inside($When(agent))

No need to worry about the agent finding notes you never intended to be part of the query.

Footnote: code tested in v5.12.0 on OS 10.6.8
Back to top
 
 

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



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #11 - Dec 21st, 2012, 9:02am
 
Thanks for all your time with this: I still can't get it to work, it created a new container called $February and moved everything into this new container, plus it created new containers for the separators I had in place.

So can you confirm that I am replacing the $When correctly:

Name: February
Display expression: $Name + "  (Total Time = " + $MyCount + ")"
Query: $February & !$AgentQuery & $February==$February(agent) & !inside($February(agent))
Action: $Container(original)=$February(agent);
Rule: $MyCount = sum(children($February(agent)),$TimeRequired);

Or should some of those $When  have stayed as $When.

Thanks again,

Graham
Back to top
 
 
  IP Logged
Graham Smith
Full Member
*
Offline



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #12 - Dec 21st, 2012, 10:11am
 
I think I misunderstood this, the $When stays as is and the (agent) is replaced with February, I shall try that now.

Nope that obviously isn't right either as that is setting up a new container called master and putting all the notes into that container (including the original master container) and still only creating aliases under February.

In spite of my example above, I did put "February" in the script, not February.

But I am not sure how I do this:

"To make it easier to make agent for other months, set the desired month/whatever 'When' value in the agent's $When and use these settings:"

The agent doesn't seem to have a when setting.



I fear this is beyond me, and I thought I was doing well until now.

Graham
Back to top
 
« Last Edit: Dec 21st, 2012, 10:43am by Graham Smith »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: agent to move note, not create alias
Reply #13 - Dec 21st, 2012, 12:20pm
 
Where did $Februrary come from?  We're trying to use values from your attribute 'When', otherwise referred to as $When. So for your agent:

So can you confirm that I am replacing the $When correctly:

Name: February
Display expression: $Name + "  (Total Time = " + $MyCount + ")"
Query: $When & !$AgentQuery & $February==$When(agent) & !inside($When(agent))
Action: $Container(original)=$when(agent);
Rule: $MyCount = sum(children($When(agent)),$TimeRequired);
When: February

In the about you are setting the When attribute value, in the agent, to February.

Side note, I'd strongly suggest you don't name the agent exactly the same as the container into which you're trying to place the notes.  I don't think the latter is this issue where but I'd wager it will bite you at some point.

Please configure the agent as above and re-test. FWIW, I'm assuming $When is a String-type user attribute. The '$' is a shorthand way to indicate I'm referring to an attribute called When.

If still having trouble, please put a version of your problem file online so fellow forum members can take a look at your code. If the data is private, please contact me via email.
Back to top
 
 

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



Posts: 66
Somerset, UK.
Re: agent to move note, not create alias
Reply #14 - Dec 21st, 2012, 1:53pm
 
Hello Mark,

I can't get this sorted.

I can't figure out what you mean by the about in the agent Sad

And with what I have done so far, the agent has acted as the container, with the aliases listed under the agent, so I haven't been trying to move  the notes into a container, only to under the agent.

The file has virtually nothing in as it's just being used for learning and its
here:

http://shared.myotis.fmail.co.uk/Shared/Tasks.tbx

I am probably running before I can walk here, as it was easy to get it all working with aliases, I didn't realise how difficult this part would be.

So while I am now keen to get it working, I could probably just use drag and drop and not bother with this, until I have been using Tinderbox more than few days.

But if the problem is obvious it would be good to find out what I am doing wrong.

Thanks,

Graham
Back to top
 
 
  IP Logged
Pages: 1 2 
Send Topic Print