Recursive Macro Tokens

Navigation:  Tokens > Macro Tokens >

Recursive Macro Tokens

Previous pageReturn to chapter overviewNext page

Recursive Macro Tokens are a special case of recursive tokens. The principle is the same; a token is converted to a string which contains one or more tokens. This in turn leads to the conversion of these tokens as part of the conversion of the original token.

 

The specificities of recursive macro tokens are in the way the recursion is introduced in the macro token evaluation. There are 2 ways in which recursion can come into the evaluation of a Macro Token.

 

The result of a macro (the sRESULT variable) might refer to another non-macro token (such as is the case in the example above). In that case Q++ behaves just as if you had manually replaced each particular occurrence of the macro token by the corresponding string containing non-macro tokens.

The result of a macro might also refer to a string containing another macro token (such as is the case in the example below).

 

In the latter case there are further steps you need to take to tell Q++ that you will be using macros for macro indices that Q++ cannot guess from the list of tokens it has scanned from the GridTemplate.

 

If you can tell, at the time of writing the macro, which other macro will be used, then you can either use the INCLUDE_MACRO compiler directive directly in the body of the macro, or set this parameter as one of the Initial Conditions of the Macros property used for the corresponding DiaryGridLine.

 

If you cannot tell, at the time of writing the macro, which other macro will be used, then you must set the INCLUDE_MACRO parameter from within the Macros property editor. This would be the case, for example, if you use an Input Variable to build the recursive token.

 

input

 nMacroIndex

var

begin

 sRESULT = '[1*' + IntToStr(nMacroIndex) + s_TokenRoot + ']'

end

 

Note that whenever using tokens recursively within a macro, the date of the token being converted as the result of a recursion is the date of the original macro token. This means that unless you want the recursively used token to be based on a different date than the original token, you should always use a DayValue of 1 when calling any token recursively from within a macro. For example, in the evaluation of a macro token [3*6DDD], if you set sRESULT to [3DDD], this will be equivalent to having had a token [6DDD] (3+3=6).


Topic 135500 updated on 09-May-2013.
Topic URL: http://www.qppstudio.net/webhelp/index.html?recursivemacrotokens.htm