Different Tokens Sharing a Macro

Navigation:  Tokens > Macro Tokens >

Different Tokens Sharing a Macro

Previous pageReturn to chapter overviewNext page

The structure of Macro Tokens allows you to use the same Macro, with the same Macro Index, for different tokens. This is often useful when you have many tokens to which you only want to apply a change of attributes (bold or color on a holiday, for example), but whose text you want to be converted normally.


Consider the sample grid to the left below. Suppose you now had to make the [1d] and [1Dddd] token red on holidays. You could change each into a macro token of a different index and then select the same macro for both.




But it is much easier to let them share a macro index. To do this you'd modify the above GridTemplate as shown on the right. Note how we have retained the TokenRoot of each token, but inserted *3 just before, to now make the 2 tokens : [1*3d] and [1*3Dddd].


Since both tokens use the same index, they will appear together in the Macros property editor, and the same macro


bRESULT = HolidayOfListOnDate('a', n_TokenDate)

// regardless of bResult replace the token by its root

sRESULT = '[' + IntToStr(n_TokenDayValue) + s_TokenRoot + ']'


would be selected for both. However, when the macro is run, Q++ will, in one case, supply 'd' as the value for the system variable s_TokenRoot, and 'Dddd' in the other case.




This allows us to set sRESULT to the value the token would have had normally, once we've decided with bRESULT if the text should be red or not.

Topic 136700 updated on 13-May-2016.
Topic URL: http://www.qppstudio.net/webhelp/index.html?usingthesamemacroonmanydiffere.htm