<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pttlink.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AIteration%2Fdoc</id>
	<title>Module:Iteration/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pttlink.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AIteration%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://wiki.pttlink.org/index.php?title=Module:Iteration/doc&amp;action=history"/>
	<updated>2026-05-04T20:35:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://wiki.pttlink.org/index.php?title=Module:Iteration/doc&amp;diff=5767&amp;oldid=prev</id>
		<title>Kg7qin: Created page with &quot;&lt;includeonly&gt;{{Module rating|release}}{{Module rating|protected}}{{Heavily used module|very|edit=sandbox}}&lt;/includeonly&gt; This module contains the functions for different templ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.pttlink.org/index.php?title=Module:Iteration/doc&amp;diff=5767&amp;oldid=prev"/>
		<updated>2022-01-20T19:14:09Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;includeonly&amp;gt;{{Module rating|release}}{{Module rating|protected}}{{Heavily used module|very|edit=sandbox}}&amp;lt;/includeonly&amp;gt; This module contains the functions for different templ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;includeonly&amp;gt;{{Module rating|release}}{{Module rating|protected}}{{Heavily used module|very|edit=sandbox}}&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
This module contains the functions for different templates, solving their '''iteration problem'''&lt;br /&gt;
:The Wikipedia template coding does not support the repetitive processing of a parameter set, &lt;br /&gt;
:which leads often to a very primitive and long chain of parameter checks in the kind of {{#tag:syntaxhighlight|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
{{#if:{{{1|}}} | perform an action with parameter 1 }}&lt;br /&gt;
{{#if:{{{2|}}} | perform an action with parameter 2 }}&lt;br /&gt;
{{#if:{{{3|}}} | perform an action with parameter 3 }}&lt;br /&gt;
{{#if:{{{4|}}} | perform an action with parameter 4 }}&lt;br /&gt;
•••&lt;br /&gt;
•••&lt;br /&gt;
{{#if:{{{33|}}} perform an action with parameter 33 }}&amp;lt;/nowiki&amp;gt;|lang=&amp;quot;text&amp;quot;}}&lt;br /&gt;
with the disadvantage that such a construct will fail as soon as there comes a 34{{exp|nd}} parm.&lt;br /&gt;
&lt;br /&gt;
I always thought that with Lua and its &amp;lt;tt&amp;gt;for&amp;lt;/tt&amp;gt; loops this  iterations should be possible, somehow.&amp;lt;br&amp;gt;&lt;br /&gt;
After long searching without any success and without an idea how to perform it, I asked at several forums&amp;lt;br&amp;gt; &lt;br /&gt;
and got finally from {{Ut|Trappist the monk|+|en}} the helping hint to solve it with a control structure like{{#tag:syntaxhighlight|&lt;br /&gt;
	local out = {}&lt;br /&gt;
	for i, v in ipairs (args) do&lt;br /&gt;
		table.insert (out, frame:expandTemplate{ title = title, args = v })&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat (out)|lang=&amp;quot;text&amp;quot;}}&lt;br /&gt;
The functions contained therein are from very simple, just one parameter to pass, &amp;lt;br&amp;gt;&lt;br /&gt;
to more complicated ones, where e.g. a pair of parameters needs kind of a flip-flop switch&amp;lt;br&amp;gt;&lt;br /&gt;
when always a tuple of e.g. an item and its correlated text needs to be passed. &amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
When there are tuples, triples etc., the &amp;lt;tt&amp;gt;table.insert&amp;lt;/tt&amp;gt; occurs, when the last element is processed;&amp;lt;br&amp;gt;&lt;br /&gt;
this performs problems when the last group is incomplete – it should be finished with empty values &amp;lt;br&amp;gt;&lt;br /&gt;
to trigger the &amp;lt;tt&amp;gt;table.insert&amp;lt;/tt&amp;gt;. The check with &amp;lt;tt&amp;gt;table.maxn&amp;lt;/tt&amp;gt; seems not to work correctly ?&amp;lt;br&amp;gt;&lt;br /&gt;
''This'' problem is solved differently, for the function &amp;quot;attribs&amp;quot; with a primitive workaround.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== File list templates ===&lt;br /&gt;
A very simple iteration, useable for everything, is performed by &amp;lt;code&amp;gt;function:iterate&amp;lt;/code&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
The three &amp;quot;Ifim &amp;quot; templates avoid to display the file itself as an 'other version'. &amp;lt;br&amp;gt;&lt;br /&gt;
There are currently five templates creating file lists with the &amp;lt;tt&amp;gt;function:filelist&amp;lt;/tt&amp;gt;&lt;br /&gt;
# {{T0|Other versions}} a vertical list (without initial)&lt;br /&gt;
# {{T0|Filelist}} a horizontal list (without initial)&lt;br /&gt;
# {{T0|Derivative versions}} a vertical list &lt;br /&gt;
# {{T0|Derived from}} a vertical list&lt;br /&gt;
# {{T0|File}} a horizontal list&lt;br /&gt;
All these templates are {{C|Autoreferencing templates|autoreferencing}}, and the support also the &amp;quot;gallery&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
=== Other file lists ===&lt;br /&gt;
The &amp;lt;tt&amp;gt;function:svglang&amp;lt;/tt&amp;gt; creates a list of just file_names and language_codes, for &lt;br /&gt;
#&amp;lt;li value=&amp;quot;6&amp;quot;&amp;gt; {{T0|Svg lang}}&lt;br /&gt;
# {{T0|Lang gallery}}&amp;lt;!-- &amp;lt;br&amp;gt;and ''using'' the &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; parameter: --&amp;gt;&lt;br /&gt;
# {{T0|Multilingual SVG diagrams}}&lt;br /&gt;
Much more is created by the &amp;lt;tt&amp;gt;function:ownbased&amp;lt;/tt&amp;gt; for the template&lt;br /&gt;
#&amp;lt;li value=&amp;quot;9&amp;quot;&amp;gt;{{T0|Own based}}&amp;lt;br&amp;gt;&lt;br /&gt;
which will handle in the ''majority of cases'' just one file, but can serve an unlimited number.&amp;lt;br&amp;gt;&lt;br /&gt;
This list can be controlled by the user to be displayed &amp;lt;tt&amp;gt;either&amp;lt;/tt&amp;gt; horizontally or vertically.&amp;lt;br&amp;gt;&lt;br /&gt;
#&amp;lt;li value=&amp;quot;10&amp;quot;&amp;gt;{{T0|Attribs}}&amp;lt;br&amp;gt;&lt;br /&gt;
The template works, whether there is a user assigned for a file, or one filename follows another.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;li value=&amp;quot;11&amp;quot;&amp;gt;{{T0|Emoji|Emotab}}&amp;lt;br&amp;gt;&lt;br /&gt;
The template displays a line of SVG emojis;  Unicode characters/emojis can be displayed with the function {{T0|Emoji|Emodis}}. 	&lt;br /&gt;
&lt;br /&gt;
=== Other iterations ===&lt;br /&gt;
* {{T\|Userlist|08}}: {{T0|Userlist}} with many formatting parameters&lt;br /&gt;
* {{T\|Colorbox|08}}: {{T0|ColorString}} and other color box templates&lt;br /&gt;
* {{T\|Legends |08}}: {{T0|Legtab}} combines single {{T0|Legend}}s&lt;br /&gt;
* {{T\|Tleparms|08}}: the metatemplate {{T0|Tle}} displays the parameter usage of a template&lt;br /&gt;
* {{T\|Navigate|08}}: {{T0|Navcat}} navigates through color categories &lt;br /&gt;
* {{T\|Emodis {{0}}|08}}: {{T0|Emoji}} displays (one or many) Unicode characters&lt;br /&gt;
:The function &amp;quot;{{T\|emodis|08}}&amp;quot; &amp;lt;u&amp;gt;dis&amp;lt;/u&amp;gt;plays Unicode characters / &amp;lt;u&amp;gt;emo&amp;lt;/u&amp;gt;jis; it can care for newlines, while &lt;br /&gt;
:The function &amp;quot;{{T\|emotab|08}}&amp;quot; displays a &amp;lt;u&amp;gt;tab&amp;lt;/u&amp;gt;le of files / &amp;lt;u&amp;gt;emo&amp;lt;/u&amp;gt;jis.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The function &amp;quot;'''incrhx'''&amp;quot; increments a hexadecimal number (parm 1) by a decimal number (parm 2).&amp;lt;br&amp;gt;&lt;br /&gt;
Valid numbers are assumed, no checking occurs !&amp;lt;br&amp;gt;&lt;br /&gt;
When parameter 2 is preceded by a minus, the first number is ''de''cremented by the second one&lt;/div&gt;</summary>
		<author><name>Kg7qin</name></author>
	</entry>
</feed>