This page will only parse completely when it is included in another page.
[template]Documentation subpage[/template]

[h="2"]Preamble[/h]
[template]sspp[/template]
This template is based on [template]tim|for[/template]. The template name was changed because there already is [template]tiw|for[/template] with a different purpose.
See also [template]tiw|loop[/template].
</noinclude>
[template]tim|for[/template]
Uses [template]tiw|for/aux[/template]
See also http://meta.wikimedia.org/wiki/Special:ParserDiffTest/Template:For
[h="2"] Description [/h]
The template calls a specified template up to 150 times, where one parameter takes each of a list of values; in addition to the variable parameter, for up to 5 parameters a fixed value can be specified.
[h="2"] Usage [/h]
<div class="bbcode_container"> <div class="bbcode_description">Code:</div> <pre class="bbcode_code" style="height:228px;">&#123;&#123;for loop<br /> &#124;call&#61;template to call<br /> &#124;what to separate the entries with (unnamed parameter; required, but can be the empty string)<br /> &#124;pc1n&#61;name of first parameter with constant value <br /> &#124;pc1v&#61;first constant value<br /> &#124;pc2n&#61;name of second parameter with constant value<br /> &#124;pc2v&#61;second constant value<br /> &#124;pc3n&#61;name of third parameter with constant value<br /> &#124;pc3v&#61;third constant value<br /> &#124;pc4n&#61;name of fourth parameter with constant value<br /> &#124;pc4v&#61;fourth constant value<br /> &#124;pv&#61;name of variable parameter<br /> &#124;prefix&#61;constant first part of the value of pv<br /> &#124;postfix&#61;constant last part of the value of pv<br /> &#124;list of 1 to 150 parameter values (without prefixes and postfixes), with separator "&#124;"<br /> (empty parameter values work in the regular way, they are &#39;&#39;not&#39;&#39; ignored like undefined ones)<br />&#125;&#125;</pre></div>The separator is unnamed, allowing it to start and/or end with [help="newlines and spaces"]newlines and spaces[/help]. This parameter should be put before the list. If a parameter value in the list contains an equals sign the list should use named parameters, at least from that point, where it should be noted that e.g. the third item in the list is parameter 4, because parameter 1 is the separator. If the separator contains an equals sign it is similarly prefixed with "1=", but in that case it cannot contain newlines and spaces at the start and end.
[h="3"]Changes from old preprocessor[/h]
To make a previous call to "for loop" work with the new preprocessor:
[list][*]replace <code>pc1=X=Y</code> with <code>pc1n=X | pc1v=Y</code>, etc.
[*]use an unnamed parameter for the separator; if empty, just enter an extra "|"
[/LIST]
[h="2"]Examples[/h]
[table] class="wikitable", border=1
!Code
!Result
|-
|
<div class="bbcode_container"> <div class="bbcode_description">Code:</div> <pre class="bbcode_code" style="height:168px;">1&#123;&#123;for loop&#124;, 1&#124;00&#124;01&#124;02&#124;03&#124;04&#124;05& #124;06&#124;07&#124;08&#124;09<br />&#124;10&#124;11&#124;12&#124;13&#124;14&#124;15& #124;16&#124;17&#124;18&#124;19<br />&#124;20&#124;21&#124;22&#124;23&#124;24&#124;25& #124;26&#124;27&#124;28&#124;29<br />&#124;30&#124;31&#124;32&#124;33&#124;34&#124;35& #124;36&#124;37&#124;38&#124;39<br />&#124;40&#124;41&#124;42&#124;43&#124;44&#124;45& #124;46&#124;47&#124;48&#124;49<br />&#124;50&#124;51&#124;52&#124;53&#124;54&#124;55& #124;56&#124;57&#124;58&#124;59<br />&#124;60&#124;61&#124;62&#124;63&#124;64&#124;65& #124;66&#124;67&#124;68&#124;69<br />&#124;70&#124;71&#124;72&#124;73&#124;74&#124;75& #124;76&#124;77&#124;78&#124;79<br />&#124;80&#124;81&#124;82&#124;83&#124;84&#124;85& #124;86&#124;87&#124;88&#124;89<br />&#124;90&#124;91&#124;92&#124;93&#124;94&#124;95& #124;96&#124;97&#124;98&#124;99<br /> &#124;call&#61;1x<br />&#125;&#125;</pre></div>|1[template]for loop|, 1|00|01|02|03|04|05|06|07|08|09
|10|11|12|13|14|15|16|17|18|19
|20|21|22|23|24|25|26|27|28|29
|30|31|32|33|34|35|36|37|38|39
|40|41|42|43|44|45|46|47|48|49
|50|51|52|53|54|55|56|57|58|59
|60|61|62|63|64|65|66|67|68|69
|70|71|72|73|74|75|76|77|78|79
|80|81|82|83|84|85|86|87|88|89
|90|91|92|93|94|95|96|97|98|99
|call=1x
[/template]
[/table]
Note that the last part of the separator is used as a prefix; the first prefix needs to be put separately.
[hr][/hr]
&#123;&#123;for loop&#124;&#45;&#124;a&#124;3&#124;&#124;c&#124;g& #124;call&#61;3x&#125;&#125; using [template]tiw|3x[/template] gives
[template]for loop|-|a|3||c|g|call=3x[/template]
&#123;&#123;for loop&#124;
&#124;a&#124;3&#124;&#124;c&#124;g&#124;call&#61;3 x&#125;&#125; gives
[template]for loop|
|a|3||c|g|call=3x[/template]
<div class="bbcode_container"> <div class="bbcode_description">Code:</div> <pre class="bbcode_code" style="height:120px;">&#123;&#124;class&#61;"wikitable sortable"<br />&#124;&#45;<br />&#33;Test<br />&#124;&#45;<br />&#124; &#123;&#123;for loop&#124;<br />&#123;&#123;&#33;&#125;&#125;&#45;<br />&#123;&#123;&#33;&#125;&#125; &#124;a&#124;b&#124;c&#124;d&#124;e&#124;call&#61; 3x&#125;&#125;<br />&#124;&#125;</pre></div>gives:
[table]class="wikitable sortable"
|-
!Test
|-
| [template]for loop|
!-
! |a|b|c|d|e|call=3x[/template]
[/table]
[h="2"]Substitution[/h]
For successive levels of substitution use one or more or the following (the first, the first two, the first three, the first four, or all)
[list][*]"subst:" in front of "for loop": substitute the call of [template]tim|for loop[/template]
[*]substf=subst: - substitute the parser functions in [template]tim|for[/template]
[*]substfa=subst: - substitute the call of auxiliary [template]tim|for/aux[/template]
[*]substa=subst: - substitute the parser functions in for/aux (reduces the number of items from 150 to the actual number)
[*]substc=subst: - substitute the calls of the user template
[/LIST]
If at least the first four are applied, and the separator contains &#123;&#123;&#33;&#125;&#125;, one can replace it with &#123;&#123;subst:&#33;&#125;&#125; to substitute that too.
For full substitution [special]ExpandTemplates[/special] can also be used.
[h="2"]Old version[/h]
Note that formerly this template had a named separator parameter sep.
[template]tl|for/aux5[/template] and [template]tiw|for loop 6[/template] may not have been adapted to the new preprocessor yet.
[h="2"]See also[/h]
[list][*][template]tim|foreach[/template]
[*][template]tim|tblb[/template]
[*][template]tiw|for loop[/template]
[*][template]tiw|loop[/template]
[*][help]Parameter default[/help]
[*][help]Array[/help]
[*][wiki]mw:Extension:LoopFunctions[/wiki]
[/LIST]

Tags for this Page

Similar Pages

  1. For loop
    By Arjan in forum Template
    Comments: 0
    Last Post: 11-23-2008, 10:37 PM

Bookmarks

Posting Permissions

Posting Permissions
  • You may not create new articles
  • You may not edit articles
  • You may not protect articles
  • You may not post comments
  • You may not post attachments
  • You may not edit your comments
BIRTHRIGHT, DUNGEONS & DRAGONS, D&D, the BIRTHRIGHT logo, and the D&D logo are trademarks owned by Wizards of the Coast, Inc., a subsidiary of Hasbro, Inc., and are used by permission. ©2002-2010 Wizards of the Coast, Inc.