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
Agent by String of months (Read 4720 times)
RobertW
Full Member
*
Offline



Posts: 23

Agent by String of months
Oct 09th, 2008, 6:07pm
 
I'm stuck on how to do this:

I want to make an agent which will show me only produce that is actually in season.

So pretend corn (maize) is in season July, August and September and peaches are in season August, September and October.

It would show me nothing in June, just corn in July, and both corn and peaches in August.

Any puzzle solvers with a take?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Agent by String of months
Reply #1 - Oct 10th, 2008, 4:19am
 
This needs two attributes - one a string type 'CurrentMonth' and a second, set type, 'InSeason'. now make an agent with this Rule:
  CurrentMonth=month(date(today));

Add this query:
  InSeason(^getFor(agent,CurrentMonth)^)

In your produce notes set the months that it is in season as month numbers 1 through 12.  So for a seasonality range August-November, InSeason would be the Set value "8;9;10;11"

For the month at time of writing (October), CurrentMonth is 10 and so any product whose InSeason contained '10' would match.

Current practice is to use $AttributeValue codes for internal coding but I couldn't get that to work, e.g. InSeason($CurrentMonth(agent)) or the like (escaping the dollar sign \$ doesn't help).  Still, ^getFor(note,attribute)^ does work though I'd be happy if someone gave me a non-export code version of the query - if such exists.

Note that the query needs to check the 'agent' value of CurrentMonth.  Don't use the 'parent' object or each note ends up checking it's own original note's parent note's value for that attribute - not what you want.

It's perhaps worth noting that the 'agent' item object was added in v4.0.0.
Back to top
 
« Last Edit: Oct 18th, 2008, 5:56pm by Mark Anderson »  

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



Posts: 23

Re: Agent by String of months
Reply #2 - Oct 18th, 2008, 5:43pm
 
So far, so good. Thanks.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print