Consider a text box that display the ascending/desending days count. Using regular tokens you get unsightly results on December 31st, when the [t-] token is zero.
It only occurs once a year, and Q++Studio will issue a warning, and you can easily go in and edit it … but there is a better way, using Macros. Replace the [t-] token by a Macro token, say [1*1t-]. The code is a single line :
bRESULT = AscendingDays(n_TokenDate) == '0'
Set the replacement text to Nothing and the mode to token only, to get 365/none on December 31st. Don't forget to handle the regular case, and set the replacement value to '[t-]' if bRESULT is false.
You may also wish to only display the ascending days when the descending days are 0. This is when the All Text in Box replacement option is useful. Use this setting and '[t+]'(note the t+, not t-) as the replacement string if bRESULT is true.
The replace All Text in Box setting can produce garbage in large textboxes with different fonts and font sizes. However, for small text boxes containing only a few elements of the same text attributes, it can be extremely useful.
Topic 108265, last updated on 19-Apr-2020