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
simple(?) $DisplayExpression query (Read 4149 times)
Rob Forsyth
Full Member
*
Offline



Posts: 63

simple(?) $DisplayExpression query
Feb 5th, 2013, 7:16am
 
The notes in my TBX all share a common prototype, whose $DisplayExpression is

$Name + " (total duration " + sum(descendants,$DurationInMonths) + " months)"

where $DurationInMonths is a user-defined numeric attribute with default value zero

The prototype's own displayed name is, as I would expect, "Note prototype (total duration 0 months)", however nearly all the actual items inheriting this prototype are displaying "true" as their name. If I look at their $DisplayExpressions they are, for example "Qualitative interviews (total duration "

At least part of the problem therefore appears (?) to be a need to coerce the sum(descendants, $DurationInMonths) to a string. I've tried format() and eval() without success, and I'm puzzled why the Prototype itself is behaving as expected

I say almost all items as there seems to be an additional gremlin at work which I suspect relates to character escaping in some way. A minority of the existing notes are not displaying "true" but rather a truncated versions of their actual $Names. As far as I can tell these are notes whose $Names contain quotation marks, parathenses and other ambiguous characters such as "+". Thus a note with $Name

Identify other potentially important metrics (team philosophy, structure, funding)

is showing $DisplayExpression

Identify other potentially important metrics (team philosophy, structure, funding) (total duration

but this is displaying as

Identify other potentially important metrics (team philosophy, structure, funding)

where as - as I said - most other items are displaying as "true"

Thanks!

Rob
Back to top
 
« Last Edit: Feb 05th, 2013, 7:17am by Rob Forsyth »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: simple(?) $DisplayExpression query
Reply #1 - Feb 5th, 2013, 9:39am
 
Are you certain  all the notes are correctly inheriting the Display Expression. To do this, make and agent that finds Prototype "X"(alter to use your actual prototype name). Query:

[tt]$Prototype=="X";[/tt]

Action:

$DisplayExpression=;

The latter force sets the attribute to use an inherited value and not a local one, as might happen if you'd test $DisplayExpression code by entering in a notes' Rename dialog rather than in that of the prototype.

I can't replicate your problem so if not the above my hunch is other factors are at play. I suggest you make a new TBX, and test the code you've made so as to be sure it works.

Is there any patter to which notes show the 'broken' expression, e.g. only notes were the sum is zero, not zero, etc.?

If (sum(descendants, $DurationInMonths).format(0)) doesn't work, I'd guess the issue is notes using local incorrect copies of the $DisplayExpression code.

Aha. Are you setting the prototype's Display Expression directly in the prototype's $DisplayExpression, or via it's $Rule.  If the latter, don't! If you must use a $Rule to do this, ensure you enclose the whole in quotes:

$DisplayExpression ='$Name + " (total duration " + sum(descendants,$DurationInMonths) + " months)"'

Note the quotes (red) enclosing the entire intended $DisplayExpression value. Note also that as the value contains double quotes the the surrounding quotes must be single.

Using a $Rule in a prototype to set $DisplayExpression is very inefficient as the notes using it inherit the $DisplayExpression and the $Rule which then re-applies the same value all over again.
Back to top
 
« Last Edit: Feb 5th, 2013, 9:39am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: simple(?) $DisplayExpression query
Reply #2 - Feb 5th, 2013, 12:04pm
 
I believe you'll find that an action or rule is trying to set the value of $DisplayExpression.  So, instead of simply inheriting the formula from the prototype, your notes are receiving an evaluated string.  And, in the example you cited, that string isn't a valid expression -- so Tinderbox does its best and just returns "true" since the "expression" is a non-empty string.

Back to top
 
 
WWW   IP Logged
Rob Forsyth
Full Member
*
Offline



Posts: 63

Re: simple(?) $DisplayExpression query
Reply #3 - Feb 7th, 2013, 9:41am
 
Dear Marks x 2

Thanks - sorry for delayed reply but Mark A's first suggesting (coercing all notes to read the default $DisplayExpression) fixed things.

Rob

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: simple(?) $DisplayExpression query
Reply #4 - Feb 7th, 2013, 1:05pm
 
@Rob. Thanks for the feedback. When testing code, it's very easy to open the 'wrong' rename and type a correction in a note (that should inherit from a prototype) rather than from the prototype. For me, the quickest way to visually check is by opening a note's Info View:



Anything attribute grey text is inheriting (prototype, preference, app default, etc.). Anything in black is set locally and thus not inheriting. For completeness, things in italics are calculated and thus read-only.

Besides the code inheritance reset method described up-thread, in info view you can also reset inheritance for an attribute.  Select the value for an attribute (the box in the right column). The middle button in the view's bottom status bar will now read "Use Defa…". Click that and the attribute's inherited value will replace the locally set one.

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