Attribute for recursive sum

I think it’s something really easy, but I must confess my innate difficulty to write rules and code!

I’m writing an screenplay and would like to have an atribute, which I will call $Time, where I would have the moment in minutes when the scene happens. I’m have already an atribute called $Duration where I designate a number of minutes for each scene. To find the value of $Time I just have to add the value of $Time in the last item in the outline with the actual value of $Duration in the scene I’m working.

It’s simple but I must confess I don’t know where to start!

how do we tell:

  • how do we know the note representing “in the scene I’m working”? It is the currently selected note?
  • What data types are $Time and $Duration?

It can be the selected note, but if I have

Note 1, $Time=0, $Duration=2
Note 2, $Time=2, $Duration= 3
Note 3, $Time=5, $Duration=2
Note 4, $Time=7, $Duration= 4
Note 5, $Time=11, $Duration= 3

I just have to sum the $Duration of the antecedents notes in the outline in order to get the $Time of the note.

And I’m using a number field, where 1 = 1 minute. It’s simpler, no?

Thanks. In that case, as the notes are all siblings, you could use this rule:

if($SiblingOrder==1){
   $Time=0;
}else{
   $Time=$Time(prevSibling)+$Duration;
}

Assumptions:

  • all notes used the rule are siblings, i.e. children of the same container, as inferred from above. * the note order, as seen in outline view, is the order in which the scenes play out from first to last.

If the above assumptions are not true , please provide details of the overall arrangement of the notes.

See more on the prevSibling designator.

I would suggest that this rule is more flexible and consistent with the data provided in the note above

$Time=($Time(prevSibling)+$Duration(prevSibling));

A problem with the previously suggested note is that if $Duration == 0 the application of the rule in that and the subsequent notes gets confused and the rules do not provide the desired answer. The suggested rule also works faster and makes rearranging notes more reliable from the perspective of the time/duration results.

1 Like

Paul and Mark, thanks a lot!

Tinderbox is amazing, but with your help, and everybody else in the forum, it shines!

Best,

Roberto

2 Likes