Tinderbox Icon

Attribute Data Type:   action
Attribute Default Value:   (not set - empty string)
Atrribute Group:   General
Attribute Inherited from Preferences?     No
Attribute Read-Only?   No

DisplayExpression allows the use to customise the way a note's name is displayed within Tinderbox. it is one of several such display expressions.

Some users find it helpful to use actions and rules to append information to not names, e.g. a word count, number of children or the value of some attribute. However, this does change the actual name of the note and can cause problems with other actions which don't expect note names to change.

DisplayExpression helps overcome this by working in conjunction with another new (read-only) attribute, DisplayName. The latter (q.v.) display's the Name of a note after the action in DisplayExpression is applied. The existing Name value is unaffected allowing other notes to make explicit reference to a given note.

For each note, Tinderbox evaluates that note's DisplayExpression to create the note's name, as displayed. However, if DisplayExpression is empty - or not a valid action syntax expression - then the note's Name value is used instead.

Example rule:

$Name +" (" + $WordCount + ")" 

...will display the note's word count in brackets at the end of the note. Thus, "Trip Report" becomes "Trip Report (579)". $Name will continue to return "Trip Report".

This attribute is of the 'action' data type. It takes a string argument which must be valid action syntax.

Subtracting two dates returns the number of days between two times, even if the result is a string such as DisplayExpression. For example:

 DisplayExpression: $Name+": "+($DueDate-"today")

will generate strings like

 Buy groceries: 7

Note the parenthesis around the second part of the expression; if omitted, the expression would be interpreted as an attempt to subtract two strings:

 ($Name+": "+$DueDate)-"today" 

If just including a date attribute in an expression it is possible to confuse Tinderbox's parrser. Assume $DemoDate for note "Project X" is 28/07/2009 17:57 (on a system using day/month order dates). Consider the following display expressions:


gives the string: '28/07/2009 17:57'

$Name + " : " + $DemoDate 

gives the number string: '3313478996'. This is because Tinderbox assumes the user is trying to do some sort of date arithmetic. The way around this is to use the format(data,formatString) operator. The latter emits a string, telling Tinderbox that all it has to do is concatenate the strings. Thus:

$Name + " : " + format($DemoDate,"D/M0/y h:mm") 

gives the string: 'Project X : 28/07/2009 17:57'

In v4.7.0, parsing was been revised to make the app better as misinterpreting literal characters as maths operators. In addition, parsing was expanded to accept conditional expressions (i.e. using 'if' statements. For example, in a TBX listing books there might be agents listing & sorting by ISBN and by Author. It would be useful if in each of the latter cases the matched note's alias showed the relevant attribute as part of the alias' screen title whilst using $Name in all other cases. Note that with a conditional expression we still need to define something for the 'no match' branch or else notes matching that condition get a display expression of nothing, which results in 'untitled' being shown on screen. Here's the expression:

if($Name(parent)=="ISBN"){$ISBN+" - "+$Name}else{if($Name(parent)=="Author"){$Author+" - "+$Name}else{$Name}} 

That's quite a long and complicated piece of code, due to the nesting and that's for only 3 conditions (match 'ISBN', match 'Author, no match). For longer pieces of code it can be useful to put the expression in a note, as the note's text. Conveniently, when doing this, line breaks in the text are ignored making it easy to split apart the various clauses in the expression to check nesting, etc. Assume the expression above has been places in a note called "c_BookDisplay". Now for tour book notes (or their prototype!) you use this DisplayExpression:


The result is the same as putting the initial code into each note's $DisplayExpression except now it is easier to maintain and edit.

Up: System Attribute List
Previous: DescendantCount  Next: DisplayName 

[Last updated: 14 Dec 2009, using v5.0]

Google search aTbRef for:  

Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
[See aTbRef CC licence Attribution/Waiver info info]

Creative Commons License

Made with Tinderbox