str = EvalToken(nDate,sToken)
sCurMonthName = EvalToken(Today(),'[Mmmm]')
This function does not limit you to the evaluation of a single token. The following example would also work as expected :
sCurMonthName = EvalToken(Today(),'The date is [Mmmm] [d]')
There are thus 2 main reasons to make the effort of evaluating a token yourself, within a macro, using the EvalToken function :
•You need the token to be evaluated with a different DayValue or LanguageTag. But in that case the token passed to sRESULT can be modified, using s_TokenRoot, to have the desired DayValue and/or LanguageTag.
sRESULT = '[' + sNewLanguageTag ->
+ IntToStr(nNewDayValue) ->
+ s_TokenRoot + ']'
•You need to "see" the result of the token evaluation within the macro code to then branch or loop in the code accordingly (though in this case you might wish to use the function PeekTokenValue instead).
Precautions to use when using this function :
•Make sure you include the token's braces (actually, if there are no braces in sToken, then Q++ will automatically add braces to the fron and back).
Note that this function will generate all the same side-effects as if the token(s) it evaluates were part of a template. For example, if the token being evaluated is a Moon phase token, then code will be generated to change the result of the macro to the appropriate Moon phase symbol. If you are just calling this function to see what the result would be, then you should use the function PeekTokenValue instead, which discards any side-effects encountered during the evaluation of tokens.
See also: PeekTokenValue.