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
DisplayExpression with conditions (Read 2637 times)
John Doernberg
Full Member
*
Offline



Posts: 37

DisplayExpression with conditions
Jul 07th, 2014, 8:45am
 
In my daybook I have the DisplayExpression of my prototype set so that notes with dates display the date ($KeyDate) first then the name. I use "if ($KeyDate) {format($KeyDate, l)+( ")+$Name} else {$Name}." It works fine.

For notes requiring future action, I assign a future date to the date attribute $FollowUpDate. I want those notes to display the $FollowUpDate first instead of the $KeyDate, at least until I complete the follow up and change the $FollowUpDate back to "never." I had thought this would be as simple as essentially copying, pasting and adjusting the conditional described in the previous paragraph -- to "if ($FollowUpDate) {format($FollowUpDate, "l")+(" ")+$Name] else {format($KeyDate, "l")+(" ")+$Name}" (I'm not yet ambitious enough to add the additional conditional that the note should display $Name if there's neither a $FollowUpDate nor a $KeyDate). But the adjusted formula doesn't work: notes display just the $Name, with no date at all. What am I doing wrong?

Thanks.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: DisplayExpression with conditions
Reply #1 - Jul 7th, 2014, 9:30am
 
Looks like a bracket error:

if ($FollowUpDate) {format($FollowUpDate, "l")+("      ")+$Name] else {format($KeyDate, "l")+("     ")+$Name}

You've used a square closing bracket ] (in red above) where you need a curly closing bracket }.

Note also a newer and more flexible way to use the format() command is the .format() operator. Thus whilst both have the same output, code like format($KeyDate, "l") may more often be seen written as $KeyDate.format( "l").
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
John Doernberg
Full Member
*
Offline



Posts: 37

Re: DisplayExpression with conditions
Reply #2 - Jul 7th, 2014, 12:17pm
 
Thank you -- the eyesight goes first. It has also been a mystery to me whether the letter in quotation marks is a capital I, a lowercase L, or a number 1. I had expected it to be a lowercase L based on the Date format explanations that I saw, but apparently it's a capital I?

Is it easy to add an additional condition: that if there's neither a $FollowUpDate nor a $KeyDate, then only the $Name should be displayed? Right now notes with neither of those dates (e.g., the prototypes) display "never" then the name of the note. It would be nice to get rid of that "never."

Thanks as always.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: DisplayExpression with conditions
Reply #3 - Jul 7th, 2014, 1:58pm
 
The format is a lowercase L, i.e. 'l'. The problem is fonts are inconsistent how the differentiate lowercase L, uppercase I, and the numeral 1. If in doubt, re-type the character with your own keyboard so it's the one you want even if the font makes it looks like something else. Date formats.

I'll take a look at the other question later - just heading out.
Back to top
 
 

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

User - not staff!

Posts: 5689
Southsea, UK
Re: DisplayExpression with conditions
Reply #4 - Jul 7th, 2014, 3:48pm
 
For such a complex set of conditions, don't do the work in $DisplayExpression. Instead, use a rule to set a user String attribute and use the latter's value as the display expression. So here is the rule, which needs an extra string attribute 'MyString':

if($FollowUpDate!="never"){
$MyString=$FollowUpDate.format("l")+("       ")+$Name;
$Color="bright blue";
} else {
if($KeyDate!="never"){
     $MyString=$KeyDate.format("l")+("       ")+$Name;
     $Color="bright red";
} else {
     $MyString=$Name;
     $Color=;
};
};


The display expression is now just this:

$MyString

Edit: I left in some test code that changes $Color so as to more easily check for changes, remove that if you don't need it.
Back to top
 
« Last Edit: Jul 8th, 2014, 4:13pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print