Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Questions and Answers >> Syntax Issues
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1186214979

Message started by Eric Abrahamsen on Aug 4th, 2007, 4:09am

Title: Syntax Issues
Post by Eric Abrahamsen on Aug 4th, 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

Title: Re: Syntax Issues
Post by Mark Bernstein on 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!

Title: Re: Syntax Issues
Post by Eric Abrahamsen on 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

Title: Re: Syntax Issues
Post by Mark Bernstein on 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!  

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.