Please enable JavaScript to view this site.

 

Navigation: Tokens > Macro Tokens

Multiple Tokens Sharing a Macro Index

Scroll Prev Up Next More

In a GridTemplate, more than one token can use the same macro index.

 

This is 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 (ie. as if there was no macro).

 

In the example below, we added macro indices to the tokens of the left to make their text red on holidays. The TokenRoot of each token was retained, but the index *3 was inserted just before the TokenRoot, changing the tokens [1d] and [1Dddd] to [1*3d] and [1*3Dddd].

 

 

Since both tokens use the same index, they will appear together in the list of macro indices of the macros property editor, as shown on the right above, and use the same macro.

 

Most macros, except those that calculate a specific text result, contain the following line of code:

 

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

 

This line of code means that the macro reads the index of the macro token to determine which macro to use, and then discards that index, so that the original token is then passed-on for further processing, as if no macro had ever been there.

 

In the present case, the values of sResult for the tokens [1*3d] and [1*3Dddd] would therefore be [1d] and [1Dddd] (back to square one).

 

 

This sets 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, last updated on 01-Aug-2020