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
Syntax Issues (Read 6769 times)
Eric Abrahamsen
Full Member
*
Offline



Posts: 3

Syntax Issues
Aug 04th, 2007, 4:09am
 
Congrats on the new version of Tinderbox – there's some excellent new stuff in there, and I've been playing happily for the past few days. This forum is also a bonus, I think – while the wiki is appropriate for knowledge-base type stuff, some things are best handled by a forum.

I wonder if, as things pick up speed, it might be worthwhile to separate out the sections a little more – I'm thinking specifically a section dedicated to agent queries, actions, and export syntax. Personally, when I have a question about Tinderbox, nine times out of ten it's because I've written an agent query that doesn't work the way I expect it to. If other people are like me, it might be worth having a dedicated space to ask these questions and get them answered. That would also make it easier to refactor the 'corrected' code statements to the wiki, where it would be very nice to have a clearly indexed database of sample code.

Anyway, whether or not we have a dedicated section for this isn't terribly important, what's nice is that the forum should make these problems easier to solve! On that note...

I've got a relatively basic agent query that nabs notes with a 'checkDate' date attribute, when that date is a certain distance from now:

checkDate<today + 20 days

Obviously it would be nice to have more flexibility on the 20 day limit, so I created a numerical attribute, called intervalDays, so that each note could have its own limit. Then I thought the query would look like this:

checkDate<today + $intervalDays days

Sadly, no dice. Many variations were tried, no dice on them either. Can anyone enlighten?

Many thanks in advance,
Eric
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Syntax Issues
Reply #1 - Aug 4th, 2007, 6:44am
 
1) Let's create a string attribute $Interval and a date attribute $TheDate
2) We'll make a container with $Interval="today+20 days"
3) The container's OnAdd rule is:

      TheDate=date($Interval)

That's easy enough.  

Now, suppose we have an integer attribute $HowOften, which happens to have a value of 5.  Can we construct Interval?

    TheDate=date("today"+"+"+$HowOften+" days")

We just construct the string in pieces. But, usually, the first approach is easier.

    What's with separating out the '+'?  It helps the Tinderbox parser avoid prematurely evaluating the incomplete date expression.  The general rule: do things in small steps; it's simpler!
Back to top
 
« Last Edit: Aug 4th, 2007, 7:14am by Mark Bernstein »  
WWW   IP Logged
Eric Abrahamsen
Full Member
*
Offline



Posts: 3

Re: Syntax Issues
Reply #2 - Aug 4th, 2007, 10:17pm
 
Hmmm, this query:
checkDate<date("today"+"+"+$intervalDays+" days")

always evaluates to false for me. But it seems like the simplest solution is to replace the numerical $interval attribute with another date attribute(say 'notifyDate'), and then have the note's rule set to
notifyDate=$checkDate+20 days

A per-note interval can still be specified, but now in the rule, not in an attribute. If the rule is a Key Attribute then it's even simpler.

Thanks!
E
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Syntax Issues
Reply #3 - Aug 5th, 2007, 10:57am
 
Functions aren't supported in queries.  So, you can say

      if(DueDate<AnnualMeetingDate)

but not

     if(DueDate<date(....) )

Why not?  Because date(....) in a query is a regular expression query!
Back to top
 
 
WWW   IP Logged
Pages: 1
Send Topic Print