<?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=How_To_Use_Variables</id>
	<title>How To Use Variables - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.drunkenfell.com/index.php?action=history&amp;feed=atom&amp;title=How_To_Use_Variables"/>
	<link rel="alternate" type="text/html" href="https://www.drunkenfell.com/index.php?title=How_To_Use_Variables&amp;action=history"/>
	<updated>2026-04-21T03:14:47Z</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=How_To_Use_Variables&amp;diff=222358&amp;oldid=prev</id>
		<title>imported&gt;Tlosk: Created page with '{{RightToC}} {{Related|Help:Contents|Wiki Templates}}  This function allows you to define a variable on a page, use it later in that same page, change its value, possibly to a va...'</title>
		<link rel="alternate" type="text/html" href="https://www.drunkenfell.com/index.php?title=How_To_Use_Variables&amp;diff=222358&amp;oldid=prev"/>
		<updated>2009-05-20T15:33:05Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;{{RightToC}} {{Related|Help:Contents|Wiki Templates}}  This function allows you to define a variable on a page, use it later in that same page, change its value, possibly to a va...&amp;#039;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:33, 20 May 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>imported&gt;Tlosk</name></author>
	</entry>
	<entry>
		<id>https://www.drunkenfell.com/index.php?title=How_To_Use_Variables&amp;diff=38458&amp;oldid=prev</id>
		<title>imported&gt;Tlosk: Created page with '{{RightToC}} {{Related|Help:Contents|Wiki Templates}}  This function allows you to define a variable on a page, use it later in that same page, change its value, possibly to a va...'</title>
		<link rel="alternate" type="text/html" href="https://www.drunkenfell.com/index.php?title=How_To_Use_Variables&amp;diff=38458&amp;oldid=prev"/>
		<updated>2009-05-20T15:33:05Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;{{RightToC}} {{Related|Help:Contents|Wiki Templates}}  This function allows you to define a variable on a page, use it later in that same page, change its value, possibly to a va...&amp;#039;&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;Tlosk</name></author>
	</entry>
</feed>