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
Computing days elapsed for User Attribute (Read 1577 times)
Art Russell
Full Member
*
Offline



Posts: 10
Jacksonville, FL
Computing days elapsed for User Attribute
Jan 07th, 2016, 10:44pm
 
For the past several years I've used Tinderbox to track the blooming of orchids in my collection of several hundred orchids.  I currently record the name ($Name), start date ($StartDate), and end date ($EndDate) for each instance of blooming orchid.  To this, I've been attempting to  add calculation of the duration of the blooms ($BloomDuration).  

I've attempted to use a Rule to compute $BloomDuration to call the days Operator [days(date1,date2)], but without success.

Key Attribute:
$StartDate - System Attribute
$EndDate - System Attribute
$BloomDate - User Attribute

In application, I've created a Prototype, "Orchids," with the Key Attributes listed above.  

In the Prototype Rules I've used the expression:
$BloomDate==days($StartDate,$EndDate).  

To date, I have not successfully returned an interval using the following dates as a test case (two notes in a container/outline):
Note 1:
$StartDate - 1/5/15, 17:56
$EndDate - 1/5/16, 17:56

Note 2:
$StartDate - 12/1/15, 17:56
$EndDate - 12/31/15, 17:47

I've also tried each of the available data types (string, color, number, ... interval), but without returning a number as suggested in http://www.acrobatfaq.com/atbref6/index/ActionsRules/Operators/FullOperatorList/....

I'm sure that I missed something obvious and would appreciate any assistance sorting this out.

Thanks.

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Computing days elapsed for User Attribute
Reply #1 - Jan 8th, 2016, 5:53am
 
I think this is your problem (in red):

$BloomDate==days($StartDate,$EndDate)

You've too many '=' there. '==' is an boolean (true/false) test of left and right side. You want to set the left side to the output of the right side, for which you use a single '='

See:
Back to top
 
 

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



Posts: 10
Jacksonville, FL
Re: Computing days elapsed for User Attribute
Reply #2 - Jan 8th, 2016, 7:33am
 
Mark,

Thanks for taking the time to comment.

I've actually tried it both as "=" and "==" with no difference in effect.

For the record, in setting Attribute type for $BloomDate, I had the following results for both uses of "=" and "==" as reflected in the $BloomDate for both Note 1 and Note 2:

String      returns "0"
Color              returns "0" and the color bar
Number      returns "0"
File              returns "0" and the file symbol
Boolean      returns check box
Date              returns never
Set            returns "0"
URL            returns "0" and url symbol (world globe)
List              returns "0"
Interval      returns "00:00"

Further thoughts?

Thanks,

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

User - not staff!

Posts: 5689
Southsea, UK
Re: Computing days elapsed for User Attribute
Reply #3 - Jan 8th, 2016, 9:50am
 
Using a rule of $MyString = days($StartDate,$EndDate), I get these results:

$StartDate - 1/5/15, 17:56 (1 Jan 2015)
$EndDate - 1/5/16, 17:56 (1 Jan 2016)

Result => 365

$StartDate - 12/1/15, 17:56  (1 Dec 2015)
$EndDate - 12/31/15, 17:47  (31 Dec 2015)

Result => 29

For instance (my UK system is day/month order for dates), in v6.4.0 looks like this for the second test:



Could you make a small test TBX that shows your problem and post a link to it so others can see the code? Sometimes things get missed in transcription. Using your data described above, the tests work as expected on my system.
Back to top
 
 

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



Posts: 10
Jacksonville, FL
Re: Computing days elapsed for User Attribute
Reply #4 - Jan 8th, 2016, 3:19pm
 
Mark,

I'm at the office and won't be able to reply with a screen shot until either late this evening or tomorrow morning (here in the States).

That being said, the only difference between our approaches is your use of a semicolon to terminate the expression and spaces on either side of the "=" - neither of which affect operation of the expression.  I did try that approach with no change in effect.

Thanks,

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

User - not staff!

Posts: 5689
Southsea, UK
Re: Computing days elapsed for User Attribute
Reply #5 - Jan 8th, 2016, 3:29pm
 
The white space makes no difference - it's parsed out when TB reads the rule.  The semi-colon is an expression terminator. In this case it's genuinely optional as the rule contains a single expression; I only added in by way using full syntax.

Screenshot of your file won't help much - I only used one to give you added confidence that the code as described does work.  some other factor is likely at play.  That's why I'd like to see and actual file that shows the erro. If it errors on your system it should on mine; special-to-user errors occur occasionally but they're normally in more complex scenarios than in one simple basic rule.

If the error is as you describe, it should work in a TBX with just notes 1 and 2 each with the data & rules as described. If so, that will be interesting to trst on other Macs. If the error is in your main data file but not in a small test file, likely you've a code typo or some unseen other action affecting things. The latter's not uncommon, as a file uses more code and the user experiments more. That's why small break-out tests help, to give you confidence that the incorrect result is a by-product of other factors.
Back to top
 
 

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



Posts: 10
Jacksonville, FL
Re: Computing days elapsed for User Attribute
Reply #6 - Jan 8th, 2016, 9:17pm
 
Mark,

Attached are both an image of the implementation of the Rule, and the test TBX file that originated it.
Image https://www.dropbox.com/s/9o9d3c0xitax53z/Test_image.png?dl=0

TBX File https://www.dropbox.com/s/343vf8iikuwtglm/test.tbx?dl=0

Thanks,

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

User - not staff!

Posts: 5689
Southsea, UK
Re: Computing days elapsed for User Attribute
Reply #7 - Jan 9th, 2016, 5:27am
 
Many thanks. The problem is broken inheritance. Although the two test notes use the prototype, they don't inherit it's rules. That is because their rules have at some point been set loccally and then the rule deleted. An empty attribute does *not* imply inheritance.

Open your test and for each test note in turn open Get Info, attributes tab, General group. You will notice $Rule has no value but the attribute name is in bold. Bold indicates the value (even if none) is set locally so doesn't inherit the app default or prototype if any. You need to reset inheritance by right-clicking on the 'Rule' label in the Get Info attribute table and click the 'use inherited Value' pop-up. The label 'Rule' should now revert to normal type and the rule will show the inherited value if any (for KAs this might be awater a short delay).

Reset the $Rule for each test note. after doing that Test 1 gives 363 and test 2 29, which I believe are the values you'd expect.

A suggestion re $BoomDate.  As it is Number-type, I'd suggest $BloomDays might be a better title. I generally only use 'Date' in an attribute name if it is Date-type. After a while it's easy to forget atribute date types and thus get the wrong hint from the attribute name. That said, call it what ever you like <g>.

Many thanks again for the screen grab and the test file. Without the TBX we'd have been chasing the 'error' (misconfigured inheritance) for some while.
Back to top
 
 

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



Posts: 10
Jacksonville, FL
Re: Computing days elapsed for User Attribute
Reply #8 - Jan 9th, 2016, 11:31am
 
Mark,

Thanks for taking a look at the TBX file for me.  You solution worked as advertised.  Also as suggested, I'll retitle BloomDate as BloomDays.

Thanks Again,

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

User - not staff!

Posts: 5689
Southsea, UK
Re: Computing days elapsed for User Attribute
Reply #9 - Jan 9th, 2016, 11:41am
 
A meta-tip here, if using prototypes is to check inheritances is working. This tutorial may be of use if getting to grips with when values are/aren't inherited.
Back to top
 
 

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