FOR
and FOREACH
loop constructions.
This plugin provides some macros which do not follow normal macro expansion rules and may behave strangely under some more advanced usage scenarios (such as when CALC is involved). Please consider replacing your usage of ForEachPlugin with one of the alternatives described in Foswiki:Support.Faq39
Tag | Description |
---|---|
%FOREACH{"_var_" in="_list_"}% body %NEXT{"_var_"}% |
Loop over _body_ setting control variable _var_ to each successive element of _list_ |
%FOR{"_var_" start="_int_" stop="_int_" step="_int_"}% body %NEXT{"_var_"}% |
Loop over _body_ setting control variable _var_ to each integer in the range start to stop in steps of step |
Parameters | Description![]() |
---|---|
in="..." |
Comma separated list. May contain Foswiki macros |
FOR | |
FOREACH | |
"step"="..." |
Increment/decrement var in steps of step . THIS IS REQUIRED |
"..." |
Loop control variable. Within the body of the text this may be referred to as $var . %FOREACH{"var" ...}% must have a matching %NEXT{"var"}% |
"..." |
Loop control variable. Within the body of the text this may be referred to as $var . %FOR{"var" ...}% must have a matching %NEXT{"var"}% |
"start"="..." |
Starting integer |
"stop"="..." |
Stop integer |
FOREACH
Examples %FOREACH{"web" in="Main, Sandbox, System"}% * [[$web.WebHome]] %NEXT{"web"}%... gives ... ... if installed.
%FOREACH{"i" in="1, 2, 3"}% %FOREACH{"j" in="a, b, c"}% $i$j %NEXT{"j"}% %NEXT{"i"}%1a 1b 1c 2a 2b 2c 3a 3b 3c
$percnt
to replace %
if necessary.
%FOREACH{"web" in="%WEBLIST{"$name" separator=", "}%"}% | $web | $percntFORMFIELD{"STATUS" topic="$web.%HOMETOPIC%" default="Formfield STATUS not defined in $web" alttext="Formfield STATUS not found in $web"}$percnt | %NEXT{"web"}%
Cerenkov | Formfield STATUS not found in Cerenkov |
Cerenkov/Pandacerenkov | Formfield STATUS not found in Cerenkov/Pandacerenkov |
DCS | Formfield STATUS not found in DCS |
Daq | Formfield STATUS not found in Daq |
Daq/Pandadaq | Formfield STATUS not found in Daq/Pandadaq |
Detector | Formfield STATUS not found in Detector |
EMC | Formfield STATUS not found in EMC |
EMPAnalysis | Formfield STATUS not found in EMPAnalysis |
Forwardstraws | Formfield STATUS not found in Forwardstraws |
GEM | Formfield STATUS not found in GEM |
MC | Formfield STATUS not found in MC |
Magnet | Formfield STATUS not found in Magnet |
Main | Formfield STATUS not found in Main |
Mvd | Formfield STATUS not found in Mvd |
PANDAMainz | Formfield STATUS not found in PANDAMainz |
PWA | Formfield STATUS not found in PWA |
Pbook | Formfield STATUS not found in Pbook |
Personalpages | Formfield STATUS not found in Personalpages |
Physics | Formfield STATUS not found in Physics |
Physics/Baryons | Formfield STATUS not found in Physics/Baryons |
Physics/CharmoniumAndExotics | Formfield STATUS not found in Physics/CharmoniumAndExotics |
Physics/HadronsInNuclei | Formfield STATUS not found in Physics/HadronsInNuclei |
Physics/OpenCharm | Formfield STATUS not found in Physics/OpenCharm |
PhysicsCmt | Formfield STATUS not found in PhysicsCmt |
SPC | Formfield STATUS not found in SPC |
STT | Formfield STATUS not found in STT |
Sandbox | Formfield STATUS not found in Sandbox |
ScrutinyGroup | Formfield STATUS not found in ScrutinyGroup |
System | Formfield STATUS not found in System |
Tagpid | Formfield STATUS not found in Tagpid |
Tagpid/Pandatagpid | Formfield STATUS not found in Tagpid/Pandatagpid |
Tagtrk | Formfield STATUS not found in Tagtrk |
Tagtrk/Pandatagtrk | Formfield STATUS not found in Tagtrk/Pandatagtrk |
Target | Formfield STATUS not found in Target |
Target/ClusterJetTarget | Formfield STATUS not found in Target/ClusterJetTarget |
Tof | Formfield STATUS not found in Tof |
WebServices | Formfield STATUS not found in WebServices |
YoungScientists | Formfield STATUS not found in YoungScientists |
ZArchives | Formfield STATUS not found in ZArchives |
FOR
Examples %FOR{"counta" start="1" stop="10" step="2"}% $counta %NEXT{"counta"}%
%FOR{"countb" start="1" stop="10" step="1"}% $countb %NEXT{"countb"}%
%FOR{"countc" start="10" stop="1" step="-1"}% $countc %NEXT{"countc"}%
%FOR{"outer" start="1" stop="3" step="1"}% %FOR{"inner" start="3" stop="1" step="-1"}% * $outer - $inner %NEXT{"inner"}% %NEXT{"outer"}%
%FOR{"countd" start="10" stop="1" step="1"}% $countd %NEXT{"countd"}%
(invalid step)
countd
: Bad step
%FOR{"counte" start="a" stop="b" step="c"}% $countd %NEXT{"counte"}%
(non-integers)
%<plugin>_<setting>%
, i.e. %INTERWIKIPLUGIN_SHORTDESCRIPTION%
data/debug.txt
) ForEachPlugin.zip
in your Foswiki installation directory. Content: File: | Description: |
---|---|
data/System/ForEachPlugin.txt | Plugin topic |
data/System/ForEachPlugin.txt,v | Plugin topic repository |
lib/Foswiki/Plugins/ForEachPlugin.pm | Plugin Perl module |
Plugin Author: | Original 2005: Magnus Lewis Smith - From 2009 Kenneth Lavrsen and put in Feel Free to Modify policy |
Release: | 1.102 |
Version: | 10382 (2010-12-22) |
Change History: | |
22 Dec 2010: | (1.102) Foswikitask:Item10183 - Add link to Foswiki:Support.Faq39 |
10 Nov 2010: | (1.101) Foswikitask:Item9993 - Fix Release Version |
04 Jun 2009: | (1.100) Ported unmodified to Foswiki by Kenneth Lavrsen |
28 Sep 2005: | (1.000) Initial version |
Foswiki Dependency: | $Foswiki::Plugins::VERSION 1.024 |
CPAN Dependencies: | none |
Other Dependencies: | none |
Perl Version: | 5.008 |
License: | GPL (GNU General Public License) |
Plugin Home: | http://foswiki.org/Extensions/ForEachPlugin |
Support: | http://foswiki.org/Support/ForEachPlugin |