This question about Topic Markup Language and applications: Answered
Evaluation order of nested macros and escaping them.
I'm just switching from TWiki to Foswiki. I like the looks of what you've done so far with Foswiki.
I'm not clear on how macros are nested and the order of evaluation. I've been trying to get a macro to work for finding the occurance of a word in topics and counting how many times it occurrs. I'm using the %CALC{}% and formatted Search.
I've tried many times at this formula and this is the latest version of it. It tries to count the occurrence of the word backup. in the It web.
%CALC{ "$SET( itemlist,%$NOP()SEARCH{ \"backup\" web=\"It\" type=\"regex\" nonoise=\"on\" multiple=\"on\" format=\"$pattern(.*(backup).*),\"}%$NOP() )" }%
Count of items: %CALC{ $COUNTITEMS($GET(itemlist))}%
The example I was working from to build the above statement would have the NOP inside the trailing % of the SEARCH function. But when ever I do that I get a list that's built from two pieces of the SEARCH statement broken at where the NOP statement is. In the statement above I at least get a list returned by the SEARCH function, but the containing SET statement isn't recognized and surrounds the returned list.
One thing I'm confused on is that I've seen examples of the CALC macro inside of SEARCH macros and it's escaped with $percnt. In the CALC function I read in a posting that the SEARCH has to be escaped with
$NOP(). I'm familiar with escape codes being used in regular expressions where it allows for a symbol that normally has a special function in the regular expression to be escaped out and be used for a different purpose. I read somewhere in the documentation that the $percnt; was used to delay execution of a macro. I'm not sure what that means.
So what are the rules for nesting macros? Are the rules different based upon what the containing macro is? Is there one or more places in the documentation that discuss this? I haven't yet found a good discussion of the evaluation of macros and how they can be nested.
--
MatthewJackson - 24 Jun 2009
Short answer: Evaluation order is from inside to outside and from left to right. General escape codes are
$percnt
and
$dollar
. I've nested alot macros the last couple of years, but never used
$NOP()
(which is a function of the SpreadSheetPlugin). I wasnt even aware, that there is a NOP().
--
OliverKrueger - 24 Jun 2009