<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://miniscript.org/w/index.php?action=history&amp;feed=atom&amp;title=Variables</id>
	<title>Variables - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://miniscript.org/w/index.php?action=history&amp;feed=atom&amp;title=Variables"/>
	<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=Variables&amp;action=history"/>
	<updated>2026-04-11T20:46:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>http://miniscript.org/w/index.php?title=Variables&amp;diff=1337&amp;oldid=prev</id>
		<title>Redspark at 02:37, 30 January 2025</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=Variables&amp;diff=1337&amp;oldid=prev"/>
		<updated>2025-01-30T02:37:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 02:37, 30 January 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l27&quot; &gt;Line 27:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 27:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Overuse of global variables can sometimes lead to tricky bugs, so it’s best to use them sparingly and rely on local variables as much as possible. MiniScript is designed so that this good practice is what happens naturally.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Overuse of global variables can sometimes lead to tricky bugs, so it’s best to use them sparingly and rely on local variables as much as possible. MiniScript is designed so that this good practice is what happens naturally.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Language]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Redspark</name></author>
		
	</entry>
	<entry>
		<id>http://miniscript.org/w/index.php?title=Variables&amp;diff=523&amp;oldid=prev</id>
		<title>JoeStrout: Created page with &quot;A ''variable'' is a word (also called an identifier) associated with a value. Think of variables as little boxes that you can store data in. You create a variable simply by as...&quot;</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=Variables&amp;diff=523&amp;oldid=prev"/>
		<updated>2020-06-03T13:30:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;A &amp;#039;&amp;#039;variable&amp;#039;&amp;#039; is a word (also called an identifier) associated with a value. Think of variables as little boxes that you can store data in. You create a variable simply by as...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A ''variable'' is a word (also called an identifier) associated with a value. Think of variables as little boxes that you can store data in. You create a variable simply by assigning a value to it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ms&amp;gt;x = 42&amp;lt;/ms&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line creates a variable called ''x'', if it didn’t exist already, and stores 42 in it. This replaces the previous value of x, if any.&lt;br /&gt;
&lt;br /&gt;
Variables in MiniScript are dynamically typed; that is, you can assign any type of data to any variable.&lt;br /&gt;
&lt;br /&gt;
Variables are always '''local''' in scope. That means that a variable called ''x'' inside one function has nothing at all to do with another variable called ''x'' in another function; each variable is scoped (restricted) to the current function executing at the time of the assignment.&lt;br /&gt;
&lt;br /&gt;
However, MiniScript also supports code outside of any function. In this context, local and global variables are the same. In other words, assigning 42 to ''x'' outside of a function creates a '''global''' variable called ''x''. Such global variables may be accessed from any context.&lt;br /&gt;
&lt;br /&gt;
Note that when a context has a local variable of the same name as a global, an identifier will always resolve to the local variable first. Similarly, a simple assignment statement within a function will always create a local variable, rather than a global one. In cases where you really need to access the global variable instead, there is a [[globals]] object that provides this access.  (There is also [[locals]] but this is rarely needed, since simple references always access locals anyway.)&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;ms&amp;gt;demo = function()&lt;br /&gt;
    print x          // prints the global x (40)&lt;br /&gt;
    x = 2            // creates a local ‘x’ with a value of 2&lt;br /&gt;
    print x          // prints the local x (2)&lt;br /&gt;
    print globals.x  // prints the global x again (40)&lt;br /&gt;
    globals.x = 42   // reassigns the global x&lt;br /&gt;
    print x          // still the local value (2)&lt;br /&gt;
    print globals.x  // prints the new global value (42)&lt;br /&gt;
end function&lt;br /&gt;
x = 40   // creates a global ‘x’ with a value of 40&lt;br /&gt;
demo     // invokes the function above&amp;lt;/ms&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overuse of global variables can sometimes lead to tricky bugs, so it’s best to use them sparingly and rely on local variables as much as possible. MiniScript is designed so that this good practice is what happens naturally.&lt;/div&gt;</summary>
		<author><name>JoeStrout</name></author>
		
	</entry>
</feed>