Navigation:  Appendices > Macro Language > Built-in Functions > All Functions (Alphabetical) >


Previous pageReturn to chapter overviewNext page

str = EvalToken(nDate,sToken)


This macro function returns the value that a token sToken will have on the date nDate. This is one of the most powerful built-in macro functions.


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]')


Note that if, at the end of a macro, sRESULT includes any tokens, they will be evaluated automatically, assuming the same DayValue and LanguageTag as those of the incoming macro token.


There are thus 2 main reasons to make the effort of evaluating a token yourself, within a macro, using the EvalToken function :


1. 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 + ']'


2. You need to "see" the result of the token evaluation within the macro code to then branch or loop in the code accordingly. This is the main reason to use this function.


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).

If the token involves holidays, make sure that you have used the functions SetCurHolidaysList and FindHolidayOnDate to initialize the holidays table.


This function cannot be evaluated at design-time, in the Macros Editor, but it is fully evaluated when you preview a Script.

Topic 105097 updated on 01-Nov-2016.
Topic URL: http://www.qppstudio.net/webhelp/index.html?evaltoken.htm