Replacing token text with something else than sResult

Navigation:  ScriptLine Properties > Macros Options > Resulting Actions > Examples >

Replacing token text with something else than sResult

Previous pageReturn to chapter overviewNext page

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++ 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 updated on 12-May-2016.
Topic URL: http://www.qppstudio.net/webhelp/index.html?replacingthetokentext.htm