Tinderbox Forum

Problem with $DisplayExpression run by an edict

I nicked a trick from Michael Becker’s @satikusala recent video which has an edict to automatically sum up the run time of scenes in a group and display it as a $DisplayExpression. However, when I run it in my TBX file, it does not display correctly, and I have no idea why.

What I am using this for is a course outline where I deliver lectures taped on video (b/c of the pandemic), and I want to keep track of the duration. So every video has a $Dauer (= duration in German) attribute, and the lecture (the $Name of which is the date on which it is uploaded) has an attribute $GesamtDauer (= overall duration) that sums up the duration of the three videos I create each week.

I run an edict which is taken verbatim from Michael’s code (except the changed variable names):
$DisplayExpression=$Name+" - Gesamtdauer: "+$GesamtDauer;

However, in Outline view what I get is an incomplete version of the result:
Bildschirmfoto 2021-04-19 um 16.49.35
although both the $GesamtDauer attribute and the $DisplayExpression attribute are correctly set:
Bildschirmfoto 2021-04-19 um 16.49.46

Basically, the $DisplayExpression cuts out a part, shortens its content to “19.04.2021-17” (instead of “19.04.2021 - Gesamtdauer: 57:17”) and displays only the last two figures rather than the full value of the attribute.

Any idea why this could be? I have no idea.
Thanks for any help!

The DisplayExpression is a formula — a recipe for deciding what to display. For example, one display expression might be


This would tell Tinderbox to, when it needs to display this note, call it by its name, followed by a colon, and then by the value of $Beginn.

Your DisplayExpression is 19.04.2021 - Gesamtdauer.... Tinderbox tries to parse this as an formula. It seems “19.04” — that looks like a perfectly reasonable number. So it’s going to be very confused!

What you want to do is to save the string you’re saving in $DisplayExpression in a string attribute — perhaps $MyString — and then for your display expression simple write


I’m afraid that’s a misunderstanding. The edict has a formula, namely

$DisplayExpression=$Name+" - Gesamtdauer: "+$GesamtDauer;

(Sorry I did not format this correctly in my original post.)

I merely had it displayed in the Displayed Attributes so I could check it was correct - and it is. So I do not quite understand what I did wrong. Should I not have the $DisplayExpression displayed attribute displayed as that confuses TBX?

That won’t work as you’re asking to set the value of $DisplayExpression to the evaluation of the right side of the equals sign, when you mean to pass that code as a string to be evaluated when $DisplayName is computed from the code in $DisplayExpression

So, what you need is:

$DisplayExpression='$Name+" - $Name+" - Gesamtdauer: "+$GesamtDauer: "+$GesamtDauer';

Note the extra single quotes around the right side. Now, the contents of $DisplayExpression is

$Name+" - Gesamtdauer: "+$GesamtDauer

Without those extra quotes, Tinderbox was trying to evaluate $Name minus the string “Gesamtdauer: plus $GesamtDauer.

Remember, when setting $DisplayExpression, indeed any Action-type attribute’s value via action code, you must enclose the whole code section in quotes. If the code already uses double-quotes, use an other set of single quotes.

Many thanks - that solves the problem! And I hope I’ll remember the special status of $DisplayExpression better in the future; I did know it once.
By the way: the first quoted line of your code doubles several entries. Just so noone reading this later is confused…