<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.drunkenfell.com/index.php?action=history&amp;feed=atom&amp;title=Help%3AVariable</id>
	<title>Help:Variable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.drunkenfell.com/index.php?action=history&amp;feed=atom&amp;title=Help%3AVariable"/>
	<link rel="alternate" type="text/html" href="https://www.drunkenfell.com/index.php?title=Help:Variable&amp;action=history"/>
	<updated>2026-06-15T11:23:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://www.drunkenfell.com/index.php?title=Help:Variable&amp;diff=76078&amp;oldid=prev</id>
		<title>imported&gt;Arkalor: moved Help:Variables to Help:Variable</title>
		<link rel="alternate" type="text/html" href="https://www.drunkenfell.com/index.php?title=Help:Variable&amp;diff=76078&amp;oldid=prev"/>
		<updated>2014-04-16T22:53:11Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;https://www.drunkenfell.com/index.php?title=Help:Variables&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Help:Variables (page does not exist)&quot;&gt;Help:Variables&lt;/a&gt; to &lt;a href=&quot;https://www.drunkenfell.com/index.php?title=Help:Variable&quot; title=&quot;Help:Variable&quot;&gt;Help:Variable&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{RightToC}}&lt;br /&gt;
{{Related|Help:Contents|Wiki Templates}}&lt;br /&gt;
&lt;br /&gt;
This function allows you to define a variable on a page, use it later in that same page, change its value, possibly to a value given by an expression in terms of the old value, etc. &lt;br /&gt;
&lt;br /&gt;
It's much like a template, only very lightweight and scoped to only a single page, so you can use many variables on a page without polluting the wiki with huge numbers of templates. &lt;br /&gt;
&lt;br /&gt;
*This function requires the [http://www.mediawiki.org/wiki/Extension:VariablesExtension Variables] Extension be installed. &lt;br /&gt;
&lt;br /&gt;
== Assigning a value to a variable ==&lt;br /&gt;
&lt;br /&gt;
=== #vardefine ===&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;{{#vardefine:&amp;lt;/nowiki&amp;gt;''variablename''|''specifiedvalue''}}&lt;br /&gt;
&lt;br /&gt;
assigns the value ''specifiedvalue'' to the (already existing or hereby introduced) variable ''variablename''.&lt;br /&gt;
&lt;br /&gt;
=== #vardefineecho ===&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;{{#vardefineecho:&amp;lt;/nowiki&amp;gt;''variablename''|''specifiedvalue''}}&lt;br /&gt;
&lt;br /&gt;
works exactly as &amp;lt;tt&amp;gt;#vardefine&amp;lt;/tt&amp;gt;, but the affected value is printed.&lt;br /&gt;
&lt;br /&gt;
== Retrieving the value of a variable (#var) ==&lt;br /&gt;
&lt;br /&gt;
The value of the variable ''variablename'' is produced by&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;{{#var:&amp;lt;/nowiki&amp;gt;''variablename''}}&lt;br /&gt;
&lt;br /&gt;
If undefined, this produces the empty string; it does not give an error message.&lt;br /&gt;
&lt;br /&gt;
It's possible to define a value for the case that the variable is undefined or void:&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;{{#var:&amp;lt;/nowiki&amp;gt;''variablename'' &amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''defaultvalue''&amp;lt;nowiki&amp;gt;}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This is equivalent to:&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;{{#if:&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;{{#var&amp;lt;/nowiki&amp;gt;:''variablename''}} |&amp;lt;nowiki&amp;gt;{{#var&amp;lt;/nowiki&amp;gt;:''variablename''}} |''defaultvalue''}}&lt;br /&gt;
but it's much shorter and better arranged.&lt;br /&gt;
&lt;br /&gt;
The value can be used in parser functions, etc.&lt;br /&gt;
&lt;br /&gt;
== #varexists ==&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;{{#varexists:&amp;lt;/nowiki&amp;gt;''variablename''}} returns ''1'' if the variable is already defined (also when the value is a void string). If the variable is not defined the return value is void.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
: ''Note that the ParserFunctions extension must also be installed to use #expr''&lt;br /&gt;
&lt;br /&gt;
Compute 2*a + b:&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;{{#expr:2*{{#var:a}}+{{#var:b}}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Add one to n:&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;{{#vardefine:n|{{#expr:{{#var:n}}+1}}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Help]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Arkalor</name></author>
	</entry>
</feed>