<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://sciwiki.sierrahelp.com/index.php?action=history&amp;feed=atom&amp;title=SCI_Studio_Tutorial_Chapter_11_-_Variables</id>
	<title>SCI Studio Tutorial Chapter 11 - Variables - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://sciwiki.sierrahelp.com/index.php?action=history&amp;feed=atom&amp;title=SCI_Studio_Tutorial_Chapter_11_-_Variables"/>
	<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_Chapter_11_-_Variables&amp;action=history"/>
	<updated>2026-08-28T20:24:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_Chapter_11_-_Variables&amp;diff=493&amp;oldid=prev</id>
		<title>Andrew Branscom: 1 revision</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_Chapter_11_-_Variables&amp;diff=493&amp;oldid=prev"/>
		<updated>2013-08-05T23:16:29Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&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: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:16, 5 August 2013&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key collectr_mwSCI-mw_:diff::1.12:old-492:rev-493 --&gt;
&lt;/table&gt;</summary>
		<author><name>Andrew Branscom</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_Chapter_11_-_Variables&amp;diff=492&amp;oldid=prev</id>
		<title>Andrew Branscom: /* Temp Variables */</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_Chapter_11_-_Variables&amp;diff=492&amp;oldid=prev"/>
		<updated>2011-01-23T00:31:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Temp Variables&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Variables==&lt;br /&gt;
&lt;br /&gt;
Like any other programming language, SCI contains variables. Variables are areas in memory used to store data which can be manipulated. Variables can be used for virtually anything. You can store numbers in them, characters, pointers to objects, strings, said blocks, and more.&lt;br /&gt;
&lt;br /&gt;
There are five different types of variables in SCI games: &amp;#039;&amp;#039;&amp;#039;local&amp;#039;&amp;#039;&amp;#039; , &amp;#039;&amp;#039;&amp;#039;global&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;parameter&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;temp&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;property&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Local variables&amp;#039;&amp;#039;&amp;#039; are declared in each script. They can be accessed by any of the methods or procedures within the same script.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Global variables&amp;#039;&amp;#039;&amp;#039; are similar to local variables, except they can be accessed by the methods and procedures of any script. These are infact the local variables of script.000 (main.sc). All of the local variables in main.sc can be accessed by any method or property in any of the 1000 possible scripts.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Parameter variables&amp;#039;&amp;#039;&amp;#039; are those which are sent to methods and procedures. These will be discussed in detail in Chapter 12.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Temp variables&amp;#039;&amp;#039;&amp;#039; operate like any other variable, but can only be accessed from within the method or procedure in which they are declared.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Property variables&amp;#039;&amp;#039;&amp;#039; are declared in each object. They can be accessed one of two ways. They can be accessed from within the object&amp;#039;s methods by name, or from other objects and procedures using the send command.&lt;br /&gt;
&lt;br /&gt;
== Manipulating Variables ==&lt;br /&gt;
&lt;br /&gt;
To manipulate variables, you use [[Operators|operators]]. We&amp;#039;ll start with the basic operators: &amp;#039;&amp;#039;&amp;#039;[[#Addition|addition (+)]]&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;[[#Subtraction|subtraction (-)]]&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;[[#Multiplication|multiplication (*)]]&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;[[#Division|division (/)]]&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;[[#Assignment|assignment (=)]]&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
===Assignment===&lt;br /&gt;
&lt;br /&gt;
The&amp;amp;nbsp; assignment operator assigns a value to a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Example:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;= score 100&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the variable named &amp;quot;score&amp;quot; is set to contain 100 as it&amp;#039;s value.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Addition===&lt;br /&gt;
&lt;br /&gt;
The addition operator adds two values&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Example:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;=score (+ 100 20)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the variable named &amp;quot;score&amp;quot; is set to contain 120 as it&amp;#039;s value (100 + 20).&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Subtraction===&lt;br /&gt;
&lt;br /&gt;
The subtraction operator subtracts two values&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Example:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;= score (- 100 20)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the variable named &amp;quot;score&amp;quot; is set to contain 80 as it&amp;#039;s value (100 - 20).&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Multiplication===&lt;br /&gt;
&lt;br /&gt;
The multiplication operator multiplies two values&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Example:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;= score (* 100 20)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the variable named &amp;quot;score&amp;quot; is set to contain 2000 as it&amp;#039;s value (100 * 20).&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Division===&lt;br /&gt;
&lt;br /&gt;
The division operator divides two values&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Example:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;= score (/ 100 20)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the variable named &amp;quot;score&amp;quot; is set to contain 5 as it&amp;#039;s value (100 / 20).&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declaring and Using Variables==&lt;br /&gt;
&lt;br /&gt;
===Local &amp;amp;amp; Global Variables===&lt;br /&gt;
&lt;br /&gt;
Local and global variables are set up in the local segment, as discussed briefly in chapter 9. The variables each begin with a name label to create an identifier for them. Following the label, you can optionally specify the array size if it will be used as an array, or the value if you wish to set it to something.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;An example of declaring the variables:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;( local&lt;br /&gt;
   // a variable with no set value, so it will be set to 0&lt;br /&gt;
   aVariable&lt;br /&gt;
   // A variable set to 30&lt;br /&gt;
   anotherVariable = 30&lt;br /&gt;
   // 30 word sized variables (60 bytes total), all set to zero&lt;br /&gt;
   anArray [30]&lt;br /&gt;
   // The six variables in the array are set, the rest will be zero&lt;br /&gt;
   aDeclaredArray [10] = (0 1 2 $ABCD 3 4 )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Examples of using the variables:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;= aVariable 100&lt;br /&gt;
Wait(aVariable)&lt;br /&gt;
= anotherVariable (* aVariable 2)&lt;br /&gt;
= anArray [ 0] 5&lt;br /&gt;
(for (= aVariable 0) (&amp;lt; aVariable 10) (++aVariable )&lt;br /&gt;
   = anArray [ aVariable ]123&lt;br /&gt;
)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The use of variables is very straight forward. For more information on the local segment, refer to the &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;javascript:void(0)&amp;quot; onclick=&amp;quot;window.open(&amp;#039;http://sierrahelp.com/SCI/Definitions/Variables.html&amp;#039;, &amp;#039;Variables&amp;#039;,&amp;#039;width=750,height=900,scrollbars=yes&amp;#039;)&amp;quot;&amp;gt;Variables section&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; from the SCI Studio Help File.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Variables===&lt;br /&gt;
&lt;br /&gt;
Parameter variables are sent to methods and procedures when called, and can be accessed within them. The variables&amp;#039; labels are defined in the method or procedure&amp;#039;s definition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;An example of declaring and using the variables:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;// two params are defined. The first named aParam, the second named anotherParam.&lt;br /&gt;
(procedure (aProc aParam anotherParam)&lt;br /&gt;
    FormatPrint (&amp;quot;The first variable is: %d, the second is: %d.&amp;quot; aParam anotherParam)&lt;br /&gt;
)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;aProc&amp;quot; is the name of the procedure. The &amp;quot;aParam&amp;quot; and &amp;quot;anotherParam&amp;quot; are the names of the parameters. This is because the SCI language is derived from the &amp;quot;Lisp&amp;quot; language.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The use of variables is very straight forward. For further information, refer to the &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;javascript:void(0)&amp;quot; onclick=&amp;quot;window.open(&amp;#039;http://sierrahelp.com/SCI/Definitions/Procedures.html&amp;#039;, &amp;#039;Procedures&amp;#039;,&amp;#039;width=750,height=750,scrollbars=yes,location=no&amp;#039;)&amp;quot;&amp;gt;Procedures section&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; from the SCI Studio Help File.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Temp Variables===&lt;br /&gt;
&lt;br /&gt;
Temp variables are allocated at the beginning of methods and procedures. They operate like any other variable, but are only accessible within the method or procedure which they are declared.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;An example of declaring and using the variables:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;( procedure (aProc )&lt;br /&gt;
    /* three variables are defined. The first named aVariable is not initialized, the second named anotherVariable is initialized to 30, the last named anArray is an uninitialized 30 variable array.*/&lt;br /&gt;
    ( var aVariable , anotherVariable= 30, anArray [ 30])&lt;br /&gt;
&lt;br /&gt;
    = aVariable 100&lt;br /&gt;
    Wait(aVariable )&lt;br /&gt;
    = anotherVariable (* aVariable 2)&lt;br /&gt;
    = anArray [0] 5&lt;br /&gt;
    (for (= aVariable 0 ) (&amp;lt; aVariable 10 ) (++aVariable)&lt;br /&gt;
       = anArray [aVariable] 123&lt;br /&gt;
    )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The use of variables is very straight forward. For more information on the local segment, refer to the &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;javascript:void(0)&amp;quot; onclick=&amp;quot;window.open(&amp;#039;http://sierrahelp.com/SCI/Definitions/Variables.html&amp;#039;, &amp;#039;Variables&amp;#039;,&amp;#039;width=750,height=900,scrollbars=yes&amp;#039;)&amp;quot;&amp;gt;Variables section&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt; from the SCI Studio Help File.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Property Variables===&lt;br /&gt;
&lt;br /&gt;
Property variables are the properties of classes and instances. When accessing them from within their owner object, they operate like any other variable. When accessing them from outside the class, the send operation is used (discussed in the previous chapter).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;An example of declaring and using the properties within a class:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sci&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;( class aClass&lt;br /&gt;
   ( properties&lt;br /&gt;
     aProperty 123&lt;br /&gt;
     anotherProperty 2456&lt;br /&gt;
   )&lt;br /&gt;
   ( method (someMethod )&lt;br /&gt;
     = aProperty 100&lt;br /&gt;
     Wait(aProperty )&lt;br /&gt;
     = anotherProperty (* aProperty 2)&lt;br /&gt;
   )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The use of variables is very straight forward. For further information, refer to the section in the &amp;lt;html&amp;gt;&amp;lt;a href=&amp;quot;http://sierrahelp.com/SCI/SCIStudio3Help/&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;SCI Studio help File&amp;lt;/a&amp;gt;&amp;lt;/html&amp;gt;.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That sums up the variables of a script. If you don&amp;#039;t fully understand them yet, don&amp;#039;t worry. Continue on with the tutorial, doing the step by step examples. When done, you should have a good grasp on them. If you still do not, come back to this chapter and read it again, and look at the links to the help file.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;float: left&amp;quot;&amp;gt;[[SCI_Studio_Tutorial_Chapter_10_-_Getting_Familiar_With_Objects|&amp;amp;lt; Previous: Chapter 10 - Getting Familiar With Objects]]&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;float: right&amp;quot;&amp;gt;[[SCI_Studio_Tutorial_Chapter_12_-_Methods_and_Procedures|Next: Chapter 12 - Methods and Procedures &amp;amp;gt;]]&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:Variables]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Andrew Branscom</name></author>
	</entry>
</feed>