This question about Topic Markup Language and applications: Answered

How do I do for i=1, ... i++ without FOREACH?

Let's say I want to do something like this

%FOR{"i" start="2" stop="10" step="1" }%
   * Set Topic_$i = ProjectPage2011p$i

How would I do that without FOREACH?

It's buried in Faq39, but VarFORMAT has a type="string" mode where you'd use the $item token (there's also a 1-based $index token).

However, you do have to generate the list of numbers to loop over manually..

  format="   * Set Topic_$item = ProjectPage2011p$item"


ALERT! NB: Set statements are the very first thing that are processed from the %BASETOPIC% only - dynamically rendered Set statements do not participate in PreferenceSettings (for that, try SetVariablePlugin).

It would be nice if the list of numbers could be generated with a core macro (it seems like it's something CALC should do, but I can't see it), perhaps raise an enhancement task for this.

Although I'm generally pretty negative about commonTagsHandler macros provided by ForEachPlugin and SpreadSheetPlugin, this particular use-case is probably justification enough to keep using it in your own wiki - we did make some effort to ensure ForEachPlugin would continue to work, late in the Foswiki 1.1 development cycle.

-- PaulHarvey - 18 Aug 2011

QuestionForm edit

Subject Topic Markup Language and applications
Extension ForEachPlugin
Status Answered
Related Topics VarFORMAT
Topic revision: r2 - 19 Aug 2011, PaulHarvey - This page was cached on 13 May 2019 - 19:38.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy