$Date expression referencing a $Number value?


(Lucas D) #1

Let’s say a note has the following rule:

$MyDate2=$MyDate1 + “2 days”

This works as expected.

However, what if, instead of the number 2, I want to use a value that comes from a $Number attribute of the note in question, e.g.:

$MyDate2=$MyDate1 + “$MyNumberAttribute days”

This doesn’t work.

One workaround is to use either an agent or even an edict to write the text of $Rule such that the actual number value of $MyNumberAttribute is used in the text of $Rule, but I have found this approach rather complicated, and it means the text of $Rule is constantly overwritten, so I can’t have any other rules.

Is there a simpler approach?

Thanks, and please let me know if my question needs clarification.


(Mark Anderson) #2

$MyDate2=$MyDate1 + ($MyNumberAttribute + " days");


(Lucas D) #3

Brilliant! Works perfectly. Many thanks.


(Mark Anderson) #4

Note for later readers. The extra parentheses used, i.e. (), make sure that although Tinderbox parses an action left to right the number value of $MyNumberAttribute and “2 days” are coerced into the form “2 days” before being added to $MyDate1. Otherwise, the value (2) of $MyNumberAttribute is added to $MyDate1 and evaluated before the final string literal is read.

This a good example of where help to indicate your intend to the action code parser.