<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://m204wiki.rocketsoftware.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=NMichell</id>
	<title>m204wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://m204wiki.rocketsoftware.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=NMichell"/>
	<link rel="alternate" type="text/html" href="https://m204wiki.rocketsoftware.com/index.php?title=Special:Contributions/NMichell"/>
	<updated>2026-05-04T22:52:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://m204wiki.rocketsoftware.com/index.php?title=Talk:Methods&amp;diff=93829</id>
		<title>Talk:Methods</title>
		<link rel="alternate" type="text/html" href="https://m204wiki.rocketsoftware.com/index.php?title=Talk:Methods&amp;diff=93829"/>
		<updated>2016-08-29T22:14:41Z</updated>

		<summary type="html">&lt;p&gt;NMichell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Comment==&lt;br /&gt;
I landed on this page to discover more about the InternalNames block so I’m hesitant to perform an Edit in case I’ve misunderstood it.&lt;br /&gt;
&lt;br /&gt;
It seems to me that the example given in this article is confusing: -&lt;br /&gt;
&lt;br /&gt;
   subroutine add(%petrol is float nameRequired optional, -&lt;br /&gt;
     %oil is float nameRequired optional)&lt;br /&gt;
     internalNames&lt;br /&gt;
     %parm.petrol is %petrol&lt;br /&gt;
     %parm.oil is %oil&lt;br /&gt;
   end internalNames&lt;br /&gt;
   ...&lt;br /&gt;
   %petrol = %petrol + %parm.petrol&lt;br /&gt;
   %oil = %oil + %parm.oil&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Surely something like...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;I&amp;gt;%parm.petrol = %valueToBeReturnedToCaller&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...would make more sense.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The explanation that follows the example compounds the problem: -&lt;br /&gt;
&lt;br /&gt;
&amp;lt;I&amp;gt;This example illustrates how if petrol and oil were private class variables, the    InternalNames block makes it possible to have parameters in a method declaration with the same name, but to avoid naming conflict or confusion between the private class variables and the parameter names.&amp;lt;/I&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
As I write this, I wonder if the situation envisaged is where the private class has a %petrol variable and the parameter name-mapping is to allow that to be distinct from the %petrol parameter. Hhmmm - that code needs a rewrite.&lt;br /&gt;
&lt;br /&gt;
Happy to be corrected if I’ve missed a trick.&lt;br /&gt;
&lt;br /&gt;
NMichell&lt;br /&gt;
&lt;br /&gt;
e: nickmichell@gmail.com&lt;br /&gt;
&lt;br /&gt;
==Response==&lt;br /&gt;
Nick,&lt;br /&gt;
&lt;br /&gt;
I think you&#039;re correct that the explanation is a bit confusing &amp;amp;ndash; maybe too clever by a half. I think the reason DHS requested this feature is so they could refer to parameters in the code as &amp;lt;code&amp;gt;%parm.whatever&amp;lt;/code&amp;gt; but not put the &amp;lt;code&amp;gt;parm.&amp;lt;/code&amp;gt; part in the method template. This was especially important for named parameters, where it would have been dumb to do stuff like:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%foo:method(parm.x=%x, parm.y=true)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
I think I&#039;d avoid discussing private/public variables altogether here as I think it&#039;s a red herring. Certainly one can have a private or public variable called &amp;lt;code&amp;gt;petrol&amp;lt;/code&amp;gt;, and while one &amp;lt;b&amp;gt;can&amp;lt;/b&amp;gt; refer to it as &amp;lt;code&amp;gt;%petrol&amp;lt;/code&amp;gt; in class code, I always advocate using &amp;lt;code&amp;gt;%this:petrol&amp;lt;/code&amp;gt;. In such a case, if there is a local variable called &amp;lt;code&amp;gt;%petrol&amp;lt;/code&amp;gt;, the only way one can get at the class variable is with &amp;lt;code&amp;gt;%this:petrol&amp;lt;/code&amp;gt;. This is pretty standard O-O stuff, and it is the way Java, C++, and other &amp;quot;traditional&amp;quot; O-O languages work.&lt;br /&gt;
&lt;br /&gt;
Sound reasonable? If so, we&#039;ll fix.&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Hi Alex,&lt;br /&gt;
&lt;br /&gt;
:Yes - removing the references to class variables would clear the waters.&lt;br /&gt;
&lt;br /&gt;
:As an aside, the standard that&#039;s now evolved here is to name parameters %i.xyz, %o.abc etc. This serves both to identify them as parameters and as inputs or outputs.&lt;br /&gt;
&lt;br /&gt;
:NMichell&lt;br /&gt;
&lt;br /&gt;
:e: nickmichell@gmail.com&lt;/div&gt;</summary>
		<author><name>NMichell</name></author>
	</entry>
	<entry>
		<id>https://m204wiki.rocketsoftware.com/index.php?title=Talk:Methods&amp;diff=93809</id>
		<title>Talk:Methods</title>
		<link rel="alternate" type="text/html" href="https://m204wiki.rocketsoftware.com/index.php?title=Talk:Methods&amp;diff=93809"/>
		<updated>2016-08-29T03:05:21Z</updated>

		<summary type="html">&lt;p&gt;NMichell: InterNames&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I landed on this page to discover more about the InternalNames block so I’m hesitant to perform an Edit in case I’ve misunderstood it.&lt;br /&gt;
&lt;br /&gt;
It seems to me that the example given in this article is confusing: -&lt;br /&gt;
&lt;br /&gt;
   subroutine add(%petrol is float nameRequired optional, -&lt;br /&gt;
     %oil is float nameRequired optional)&lt;br /&gt;
     internalNames&lt;br /&gt;
     %parm.petrol is %petrol&lt;br /&gt;
     %parm.oil is %oil&lt;br /&gt;
   end internalNames&lt;br /&gt;
   ...&lt;br /&gt;
   %petrol = %petrol + %parm.petrol&lt;br /&gt;
   %oil = %oil + %parm.oil&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Surely something like...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;I&amp;gt;%parm.petrol = %valueToBeReturnedToCaller&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...would make more sense.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The explanation that follows the example compounds the problem: -&lt;br /&gt;
&lt;br /&gt;
&amp;lt;I&amp;gt;This example illustrates how if petrol and oil were private class variables, the    InternalNames block makes it possible to have parameters in a method declaration with the same name, but to avoid naming conflict or confusion between the private class variables and the parameter names.&amp;lt;/I&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
As I write this, I wonder if the situation envisaged is where the private class has a %petrol variable and the parameter name-mapping is to allow that to be distinct from the %petrol parameter. Hhmmm - that code needs a rewrite.&lt;br /&gt;
&lt;br /&gt;
Happy to be corrected if I’ve missed a trick.&lt;br /&gt;
&lt;br /&gt;
NMichell&lt;br /&gt;
&lt;br /&gt;
e: nickmichell@gmail.com&lt;/div&gt;</summary>
		<author><name>NMichell</name></author>
	</entry>
	<entry>
		<id>https://m204wiki.rocketsoftware.com/index.php?title=Enumerations&amp;diff=67594</id>
		<title>Enumerations</title>
		<link rel="alternate" type="text/html" href="https://m204wiki.rocketsoftware.com/index.php?title=Enumerations&amp;diff=67594"/>
		<updated>2014-02-24T02:23:35Z</updated>

		<summary type="html">&lt;p&gt;NMichell: Added &amp;lt;/P&amp;gt; just before &amp;quot;Using user enumerations&amp;quot;. Absence was causing &amp;quot;cookieShape is enumeration shape&amp;quot; to show as main body text, not code.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Enumerations --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Objects may have properties that can have relatively few&lt;br /&gt;
values, such as True or False; Yes, No, or Maybe; Red, Green,&lt;br /&gt;
or Blue; or Small, Medium, Large, SuperSize.&lt;br /&gt;
These properties could be defined with a string datatype, in which case&lt;br /&gt;
they would be set to values like &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;.&lt;br /&gt;
Or they could be&lt;br /&gt;
defined with a numeric datatype like &amp;lt;var&amp;gt;Float&amp;lt;/var&amp;gt;, in which case they would&lt;br /&gt;
be set to values like &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
Both of these options are unappealing:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Using strings ties you to a particular case-sensitive representation&lt;br /&gt;
of the values.&lt;br /&gt;
&amp;lt;li&amp;gt;Using numbers makes the code unclear, as the meaning of, say, 2 is not&lt;br /&gt;
readily apparent.&lt;br /&gt;
&amp;lt;li&amp;gt;Neither strings nor numbers provide any compile-time validation of values.&lt;br /&gt;
That is, if the value of a property can be either &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;,&lt;br /&gt;
the compiler will allow the property to be set to &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt;,&lt;br /&gt;
or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;, or anything else, for that matter.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The special type of class called &#039;&#039;&#039;enumerations&#039;&#039;&#039;&lt;br /&gt;
solves these problems.&lt;br /&gt;
An enumeration class doesn&#039;t actually describe a set of objects but a set of&lt;br /&gt;
values or, more specifically, names for a set of values.&lt;br /&gt;
Since values are syntactically nouns, as are objects, enumeration handling is very&lt;br /&gt;
similar to object handling.&lt;br /&gt;
&amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; supports &#039;&#039;&#039;system enumerations&#039;&#039;&#039; (pre-defined&lt;br /&gt;
in the &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Model 204&amp;lt;/var&amp;gt; nucleus) as well as&lt;br /&gt;
&#039;&#039;&#039;user enumerations&#039;&#039;&#039; (defined within a &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; request.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Declaring enumeration variables== &lt;br /&gt;
Enumeration variables are declared very much like objects:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Enumeration&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;className&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;Initial&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration is so heavily used that the keyword&lt;br /&gt;
&amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; is optional for &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration variables:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Boolean&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;Initial&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%myAim   is boolean&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
An &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; variable, like an &amp;lt;var&amp;gt;Object&amp;lt;/var&amp;gt; variable can be null;&lt;br /&gt;
in fact this the the default initial value for all enumeration variables.&lt;br /&gt;
This means that certain operations on enumeration variables can result&lt;br /&gt;
in null-pointer reference errors.&lt;br /&gt;
It also means that, in some sense, all enumerations contain a special value&lt;br /&gt;
of &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; (though &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; behaves somewhat differently from other values).&lt;br /&gt;
This means that caution should be used for inequality tests on enumeration&lt;br /&gt;
variables as a null will satisfy an inequality test.&lt;br /&gt;
 &lt;br /&gt;
Enumeration variables, including &amp;lt;var&amp;gt;Booleans&amp;lt;/var&amp;gt;, can have a&lt;br /&gt;
compile-time initial value as specified by an &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%myAim   is boolean initial(true)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
Such a clause can also be placed on variables in a class &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt;, or&lt;br /&gt;
&amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; block:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class alison&lt;br /&gt;
  public&lt;br /&gt;
     variable myaim   is boolean initial(true)&lt;br /&gt;
     ...&lt;br /&gt;
  end public&lt;br /&gt;
  ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
As with other variable types, an &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause in a &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; block&lt;br /&gt;
sets the initial value for the variable when the containing object is&lt;br /&gt;
instantiated.&lt;br /&gt;
 &lt;br /&gt;
The sections that follow describe how to use enumerations, including the methods&lt;br /&gt;
that may be applied to them.&lt;br /&gt;
Most of the individual enumeration classes are documented elsewhere: in the&lt;br /&gt;
context of the (typically one) system class method&lt;br /&gt;
that uses the enumeration.&lt;br /&gt;
&lt;br /&gt;
==Using enumerations==&lt;br /&gt;
An explicit &amp;lt;var&amp;gt;New&amp;lt;/var&amp;gt; method is &#039;&#039;&#039;not&#039;&#039;&#039; allowed for enumeration variables.&lt;br /&gt;
Instead, they must be set from the possible values for the enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = %(boolean):true&lt;br /&gt;
 ...&lt;br /&gt;
%well = %(boolean):false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values are similar to shared properties of an object class and,&lt;br /&gt;
as with other shared properties, an enumeration variable can be used instead&lt;br /&gt;
of the class name to reference the shared properties:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = %well:true&lt;br /&gt;
 ...&lt;br /&gt;
%well = %well:false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Or, because the class can be inferred from the target,&lt;br /&gt;
enumerations can be set using just the value name:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = true&lt;br /&gt;
 ...&lt;br /&gt;
%well = false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
You can also use just the value name&lt;br /&gt;
when a method parameter is an enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class customer&lt;br /&gt;
   public&lt;br /&gt;
      subroutine setActive(%active is enumeration boolean)&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer  is object customer&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer:setActive(false)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Often, though, an enumeration will be a property rather than a&lt;br /&gt;
parameter.&lt;br /&gt;
The previous example would probably be recast as:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class customer&lt;br /&gt;
   public&lt;br /&gt;
      property active is enumeration boolean&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer  is object customer&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer:active = false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
System enumerations&lt;br /&gt;
can be declared with an explicit &amp;quot;system&amp;quot; on their declaration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration system:boolean&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumerations have a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method that returns the&lt;br /&gt;
string form of a value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 &lt;br /&gt;
%active = true&lt;br /&gt;
 &lt;br /&gt;
print %active:toString&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;imp2str&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;!-- Prior to &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.3 --&amp;gt;&lt;br /&gt;
Explicitly calling the &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method was formerly required to&lt;br /&gt;
display the string form of an enumeration value, and simply&lt;br /&gt;
specifying &amp;lt;code&amp;gt;print %active&amp;lt;/code&amp;gt; in the example above was an error,&lt;br /&gt;
because &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; is an object, not a string. &lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
However, now that explicitly specifying&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is optional, a statement like &amp;lt;code&amp;gt;print %active&amp;lt;/code&amp;gt;&lt;br /&gt;
automatically implies &amp;lt;code&amp;gt;print %active:toString&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is described further in [[#Calling ToString implicitly|Calling ToString implicitly]], below. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enumerations can also have other methods.&lt;br /&gt;
One class of such methods are &amp;quot;Is&amp;quot; methods that return&lt;br /&gt;
&amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; depending on whether the method has a particular&lt;br /&gt;
value.&lt;br /&gt;
 &lt;br /&gt;
For example, the following method tests if&lt;br /&gt;
the value of &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
if %active:isTrue then&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
This is almost exactly equivalent to the following:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
if %active eq true then&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The one difference between the two forms is that the former would cause&lt;br /&gt;
a null-pointer-reference request cancellation if &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; had never&lt;br /&gt;
been set, while the latter would simply evaluate &amp;lt;code&amp;gt;%active eq true&amp;lt;/code&amp;gt;&lt;br /&gt;
as false, since a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; value is not equal to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
There is an alternative to using these &amp;lt;var&amp;gt;Is&amp;lt;/var&amp;gt; methods for &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumerations&lt;br /&gt;
in the context of an &amp;lt;var&amp;gt;If&amp;lt;/var&amp;gt; statement:&lt;br /&gt;
automatic conversion of&lt;br /&gt;
a &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;True&amp;lt;/var&amp;gt; to a 1, and of a &amp;lt;var&amp;gt;False&amp;lt;/var&amp;gt; to a 0.&lt;br /&gt;
See [[#Using Boolean enumerations|Using Boolean enumerations]]. &amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
It is possible to use enumerations without ever declaring a variable&lt;br /&gt;
with that enumeration.&lt;br /&gt;
For example, one can set the &amp;lt;var&amp;gt;UseDefault&amp;lt;/var&amp;gt; property of a&lt;br /&gt;
&amp;lt;var&amp;gt;[[NamedArraylist class|NamedArraylist]]&amp;lt;/var&amp;gt; by just using the enumeration value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%description is collection NamedArraylist of string len 64&lt;br /&gt;
  ...&lt;br /&gt;
%description:useDefault = true&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Common enumeration methods==&lt;br /&gt;
The methods listed below are available to all system enumerations. The individual method descriptions follow.&lt;br /&gt;
&amp;lt;ul class=&amp;quot;nobul&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#Copy function|Copy]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#DeepCopy function|DeepCopy]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#FromString function|FromString]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#ToString property|ToString]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[#Using Boolean enumerations|versatile]] &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration has additional methods available.&lt;br /&gt;
&lt;br /&gt;
===Copy function===&lt;br /&gt;
This function returns an exact copy of the method object.&lt;br /&gt;
It is identical to the &amp;lt;var&amp;gt;[[#DeepCopy function|DeepCopy]]&amp;lt;/var&amp;gt; method.&lt;br /&gt;
Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no&lt;br /&gt;
different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]].&lt;br /&gt;
As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an&lt;br /&gt;
enumeration variable, and the presence of these methods simply&lt;br /&gt;
makes the copyability of enumeration variables explicit.&lt;br /&gt;
&lt;br /&gt;
====Copy syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%cop&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:Copy&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%cop&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable to contain the copy of &#039;&#039;enum&#039;&#039;. &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;%cop&amp;lt;/var&amp;gt; does not have to be [[XmlDoc API#XmlDoc states|empty]].&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The method object (&amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;) may be &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt;.&lt;br /&gt;
The output of a copy of a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object is a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
===DeepCopy function===&lt;br /&gt;
This function returns an exact copy of the method object.&lt;br /&gt;
It is identical to the &amp;lt;var&amp;gt;[[#Copy function|Copy]]&amp;lt;/var&amp;gt; method.&lt;br /&gt;
Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no&lt;br /&gt;
different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]].&lt;br /&gt;
As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an&lt;br /&gt;
enumeration variable, and the presence of these methods simply&lt;br /&gt;
makes the copyability of enumeration variables explicit.&lt;br /&gt;
&lt;br /&gt;
====DeepCopy syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%dcop&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:DeepCopy&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%dcop&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable to contain the deep copy of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;. &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;%dcop&amp;lt;/var&amp;gt; does not have to be [[XmlDoc API#XmlDoc states|empty]].&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The method object (&amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;) may be &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt;.&lt;br /&gt;
The output of a deep copy of a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object is a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
===FromString function===&lt;br /&gt;
&amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; is a [[Notation conventions for methods#Shared methods|shared]] function that converts a string argument into a value of the specified enumeration type.&lt;br /&gt;
This is the opposite of the enumeration &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method, which converts an enumeration value to its &amp;lt;var&amp;gt;String&amp;lt;/var&amp;gt; representation.&lt;br /&gt;
&amp;lt;!-- &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; is available as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; Version 7.8. --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====FromString syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%enum&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;= [%(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enumType&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;):]&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;FromString(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;string&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or expression.  &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;&amp;lt;var class=&amp;quot;nobr&amp;quot;&amp;gt;%(&amp;lt;i&amp;gt;enumType&amp;lt;/i&amp;gt;)&amp;lt;/var&amp;gt; &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This explicit specification of the enumeration type in parentheses denotes a [[Object variables#Virtual Constructor methods|virtual constructor]]. See [[#Usage notes|&amp;quot;Usage notes&amp;quot;]], below, for more information about invoking this function. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;string&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;A [[Longstrings|longstring]] variable that is assigned the current string value of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Usage Notes====&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;As an example, consider the following user-defined enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration Animal&lt;br /&gt;
    public&lt;br /&gt;
      value cat&lt;br /&gt;
      value dog&lt;br /&gt;
      value gecko&lt;br /&gt;
      value parrot&lt;br /&gt;
    end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can populate an &amp;lt;code&amp;gt;Animal&amp;lt;/code&amp;gt; enumeration variable with one of the &amp;lt;code&amp;gt;Animal&amp;lt;/code&amp;gt; enumeration values by making a call to &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt;:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet is enumeration animal&lt;br /&gt;
%pet = fromString(&#039;gecko&#039;)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The result of a &amp;lt;var&amp;gt;Print&amp;lt;/var&amp;gt; of &amp;lt;code&amp;gt;%pet&amp;lt;/code&amp;gt; above is &amp;lt;code&amp;gt;gecko&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; In the method call, &amp;lt;code&amp;gt;fromString&amp;lt;/code&amp;gt; might but does &#039;&#039;&#039;not&#039;&#039;&#039; have to be preceded by &amp;lt;code&amp;gt;%(Animal):&amp;lt;/code&amp;gt; to identify the type of enumeration, because the type is determined from the result variable. You could also get the same result from invoking with an already defined enumeration variable, as in:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet = %pet:fromString(&#039;gecko&#039;)&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;li&amp;gt;Only strings that match a value of the particular enumeration type&lt;br /&gt;
can be converted. If a string cannot be converted to an enumeration&lt;br /&gt;
value, &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; throws an &amp;lt;var&amp;gt;[[InvalidValue class|Invalidvalue]]&amp;lt;/var&amp;gt; exception:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet = fromString(&#039;alien&#039;)&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;  1  CANCELLING REQUEST: MSIR.0750: Class Animal, function&lt;br /&gt;
FromString: InvalidValue exception: ALIEN is not a valid enumeration&lt;br /&gt;
value in line 84, procedure ENUM, file MYPROC&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ToString property===&lt;br /&gt;
This non-settable property examines an enumeration&lt;br /&gt;
and returns a printable or testable string representation of its value.&lt;br /&gt;
&lt;br /&gt;
====ToString syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%ls&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:ToString&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%ls&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;A [[Longstrings|longstring]] variable that is assigned the current string value of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;printenum&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
====Calling ToString implicitly====&lt;br /&gt;
&amp;lt;!-- As of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.3 --&amp;gt;To return a string representation of the value of a &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; system or user-defined enumeration, you can do either of the following:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Explicitly specify the &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Print (or audit) the value of an enumeration, and &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is implied,&lt;br /&gt;
as shown in the following example:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;begin&lt;br /&gt;
enumeration color&lt;br /&gt;
   public&lt;br /&gt;
      value red&lt;br /&gt;
      value white&lt;br /&gt;
      value blue&lt;br /&gt;
      value green&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
 &lt;br /&gt;
%x  is boolean initial(true)&lt;br /&gt;
%z  is enumeration color initial(blue)&lt;br /&gt;
%daem is object daemon&lt;br /&gt;
 &lt;br /&gt;
%daem = new&lt;br /&gt;
 &lt;br /&gt;
print %x with &#039; &#039; %z&lt;br /&gt;
[[PrintText statement|printText]] {~} = {%x}, {~} = {%z}&lt;br /&gt;
print %daem:haveDaemon&lt;br /&gt;
printText {~} = {%daem:haveDaemon}&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The &amp;lt;var&amp;gt;Print&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;PrintText&amp;lt;/var&amp;gt; statements above produce these results:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;True blue&lt;br /&gt;
%x = True, %z = blue&lt;br /&gt;
True&lt;br /&gt;
%daem:haveDaemon = True&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
In addition, the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; feature extends beyond enumerations:&lt;br /&gt;
upon any attempt to print or audit any object value, &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; will try to apply a&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method to the object.&lt;br /&gt;
If the object is an enumeration (as shown above) or is an&lt;br /&gt;
instance of a system or user-defined class that has a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method,&lt;br /&gt;
a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is implicitly&lt;br /&gt;
applied and the result is a successful print or audit of the object value.&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
For example, the user-defined class in the following request includes a&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method.&lt;br /&gt;
The request&#039;s &amp;lt;code&amp;gt;printText&amp;lt;/code&amp;gt; statement prints &amp;lt;code&amp;gt;%x = a=11, b=22&amp;lt;/code&amp;gt;. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;begin&lt;br /&gt;
class mumble&lt;br /&gt;
  public&lt;br /&gt;
    variable   a is float&lt;br /&gt;
    variable   b is float&lt;br /&gt;
    constructor new(%a is float nameRequired, %b is float)&lt;br /&gt;
    function tostring is longstring&lt;br /&gt;
  end public&lt;br /&gt;
  constructor new(%a  is float nameRequired, %b is float)&lt;br /&gt;
    %this:a = %a&lt;br /&gt;
    %this:b = %b&lt;br /&gt;
  end constructor&lt;br /&gt;
  function tostring is longstring&lt;br /&gt;
    return &#039;a=&#039; with %a with &#039;, b=&#039; with %b&lt;br /&gt;
  end function&lt;br /&gt;
end class&lt;br /&gt;
 &lt;br /&gt;
   %x   is object mumble&lt;br /&gt;
   %x = new(a=11, b=22)&lt;br /&gt;
   printText {~} = {%x}&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
If the object you try to print or audit directly is not an enumeration or is&lt;br /&gt;
an instance of a class that does not have a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method (system or&lt;br /&gt;
user-written), you receive a compilation error.&lt;br /&gt;
For example, if &amp;lt;code&amp;gt;%sl&amp;lt;/code&amp;gt; is a &amp;lt;var&amp;gt;Stringlist&amp;lt;/var&amp;gt; object, no user &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method exists,&lt;br /&gt;
and your request contains a &amp;lt;code&amp;gt;Print %sl&amp;lt;/code&amp;gt; statement, you get a message&lt;br /&gt;
like the following: &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;&amp;amp;#42;**  1  MSIR.0733: Member TOSTRING not found in class STRINGLIST&lt;br /&gt;
  print %sl&lt;br /&gt;
  (FILE = JALWORK, PROCEDURE = FOO, LINE = 28)&lt;br /&gt;
&amp;amp;#42;**  M204.1042: COMPILATION ERRORS&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
Finally, if the object you try to print directly is a &amp;lt;var&amp;gt;Unicode&amp;lt;/var&amp;gt; variable,&lt;br /&gt;
&amp;lt;!-- under &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.6 and higher --&amp;gt;&lt;br /&gt;
the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method returns an EBCDIC character-encoded value for&lt;br /&gt;
Unicode characters that do not translate to EBCDIC.&lt;br /&gt;
This is described further in [[Unicode#Implicit Unicode conversions|&amp;quot;Implicit Unicode conversions&amp;quot;]]. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Boolean enumeration==&lt;br /&gt;
The [[Boolean enumeration]] is probably the most commonly used, and so the most important enumeration class. Because of its importance, it is treated specially by &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt;, and is a topic unto itself.&lt;br /&gt;
&lt;br /&gt;
==User enumerations==&lt;br /&gt;
While there are a wide variety of system enumerations that can be useful in&lt;br /&gt;
many contexts (especially the &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration), it is&lt;br /&gt;
also possible to define user enumerations in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt;.&lt;br /&gt;
This is done via the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; statement/block, which is very similar to the&lt;br /&gt;
&amp;lt;var&amp;gt;Class&amp;lt;/var&amp;gt; statement/block (as in [[Classes and Objects|&amp;quot;Classes and objects&amp;quot;]]).&lt;br /&gt;
&lt;br /&gt;
===The Enumeration block===&lt;br /&gt;
The &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; block can contain &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt;, and &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; blocks, just like any other class.&lt;br /&gt;
However, because enumeration classes don&#039;t really describe objects, there&lt;br /&gt;
can be no instance variables.&lt;br /&gt;
That is, the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; blocks cannot contain &amp;lt;var&amp;gt;Variable&amp;lt;/var&amp;gt; declarations.&lt;br /&gt;
 &lt;br /&gt;
Instead, the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block must contain one or more &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declarations&lt;br /&gt;
whose syntax is:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Value&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;attribute&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Each value declared by a &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declaration becomes one of the values of the enumeration. &lt;br /&gt;
&lt;br /&gt;
One or more &#039;&#039;&#039;attributes&#039;&#039;&#039; (a constant datum of type &amp;lt;var&amp;gt;String&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Float&amp;lt;/var&amp;gt;, or &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt;) can be attached to an enumeration value. &amp;lt;!-- (as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.8) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
No values or attributes are allowed in the &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; blocks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The value in a &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause is unusual in that the case (lower or upper)&lt;br /&gt;
of the characters in its value are saved and used in the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method. The same is true for the values in an &amp;lt;var&amp;gt;Attribute&amp;lt;/var&amp;gt; clause. &amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The following is an example of a simple enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shape&lt;br /&gt;
   public&lt;br /&gt;
      attribute code is string &lt;br /&gt;
&lt;br /&gt;
      value triangle      (code=&#039;31&#039;)&lt;br /&gt;
      value square        (code=&#039;44&#039;)&lt;br /&gt;
      value rhombus       (code=&#039;42&#039;)&lt;br /&gt;
      value rectangle     (code=&#039;41&#039;)&lt;br /&gt;
      value quadrilateral (code=&#039;40&#039;)&lt;br /&gt;
      value pentagon      (code=&#039;50&#039;)&lt;br /&gt;
      value circle        (code=&#039;01&#039;)&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All attributes must be declared before any value is declared. In a given &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;A specification for each attribute must be explicitly present.  &lt;br /&gt;
&amp;lt;li&amp;gt;An attribute may be specified by name or by position; and like a method [[Methods#Named_parameters|named parameter]], an attribute specified with its name may not precede an attribute specified only by position.&lt;br /&gt;
&amp;lt;li&amp;gt;An attribute name may not repeat.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
Just as for &amp;lt;var&amp;gt;Class&amp;lt;/var&amp;gt; blocks, &amp;lt;!-- as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.3 --&amp;gt;&lt;br /&gt;
an &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; block you declare inside a method or complex subroutine&lt;br /&gt;
must be preceded by the keyword &amp;lt;var&amp;gt;Local&amp;lt;/var&amp;gt;.&lt;br /&gt;
For more information about locally-scoped classes and enumerations,&lt;br /&gt;
see [[Local and Common entities#Local classes, enumerations, and structures|&amp;quot;Local classes, enumerations, and structures&amp;quot;]].&lt;br /&gt;
&amp;lt;/P&amp;gt;&lt;br /&gt;
===Using user enumerations=== &lt;br /&gt;
You can use user-defined enumerations just like system enumerations.&lt;br /&gt;
That is, variables are declared with the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; keyword and class name:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape is enumeration shape&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values may be assigned to an enumeration variable:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape = circle&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Such a variable may be printed (&amp;lt;code&amp;gt;Print %cookieShape&amp;lt;/code&amp;gt;), and it may be used to access an enumeration attribute:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;Print %cookieShape:code&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More commonly, enumerations may be used as method parameters:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class cookie&lt;br /&gt;
   ...&lt;br /&gt;
   subroutine cut(%shape is enumeration shape)&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And, typically, literal values are used as the arguments when invoking&lt;br /&gt;
such a method:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%biscuit   is object cookie&lt;br /&gt;
 ...&lt;br /&gt;
%biscuit:cut(pentagon)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values are not strings, so they are case insensitive.&lt;br /&gt;
While the class of an enumeration value can almost always be determined&lt;br /&gt;
from context, the class name can always be explicitly specified for a&lt;br /&gt;
value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape = %(shape):circle&lt;br /&gt;
 ...&lt;br /&gt;
%biscuit:cut(%(shape):pentagon)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Like system enumerations, user enumeration variables can be in a state where&lt;br /&gt;
they have no value, that is, they can be null.&lt;br /&gt;
In fact, that is the initial value of any enumeration variable.&lt;br /&gt;
&lt;br /&gt;
As with system enumerations, you can change the default initial value&lt;br /&gt;
with the &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause on the variable declaration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Enumeration&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enumerationName&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Initial&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can set the default initial value for local variables:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cutout is enumeration shape initial(square)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And you can set it for variables in class blocks:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class cookie&lt;br /&gt;
   public&lt;br /&gt;
      variable shape is enumeration shape initial(round)&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Of course, instance-specific (non-&amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt;) initial values are set&lt;br /&gt;
for each instance of the class when it is created.&lt;br /&gt;
&lt;br /&gt;
===Enumeration methods===&lt;br /&gt;
Enumeration classes can also contain methods that operate on&lt;br /&gt;
or are related to the enumeration values.&lt;br /&gt;
For example, the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration can have a method that returns the number&lt;br /&gt;
of sides in a shape:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shape&lt;br /&gt;
   public&lt;br /&gt;
      ...&lt;br /&gt;
      function sides is float&lt;br /&gt;
   end public&lt;br /&gt;
   function sides is float&lt;br /&gt;
      if %this eq circle then&lt;br /&gt;
         return 0&lt;br /&gt;
      end if&lt;br /&gt;
      if %this eq triangle then&lt;br /&gt;
         return 3&lt;br /&gt;
      end if&lt;br /&gt;
      ...&lt;br /&gt;
   end function&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
As this example illustrates, the implicit &amp;lt;code&amp;gt;%this&amp;lt;/code&amp;gt; variable for enumeration&lt;br /&gt;
methods contains not an object reference but an enumeration value.&lt;br /&gt;
 &lt;br /&gt;
Enumeration methods can be applied to enumeration values as well as enumeration variables.&lt;br /&gt;
This is one case, however, where the enumeration value &#039;&#039;&#039;must&#039;&#039;&#039;&lt;br /&gt;
be qualified with the class name, because it appears in a context where&lt;br /&gt;
the class cannot be determined otherwise:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;print %(shape):rhombus:sides&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And, as with objects, an enumeration method could be applied to the output&lt;br /&gt;
of another method that returns an enumeration value.&lt;br /&gt;
For example, if the &amp;lt;code&amp;gt;PickCookie&amp;lt;/code&amp;gt; method of the &amp;lt;code&amp;gt;Jar&amp;lt;/code&amp;gt; class returns a&lt;br /&gt;
&amp;lt;code&amp;gt;Cookie&amp;lt;/code&amp;gt; object, and the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; method of the &amp;lt;code&amp;gt;Cookie&amp;lt;/code&amp;gt; class returns a&lt;br /&gt;
&amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration value, the following prints the number of sides of&lt;br /&gt;
a picked cookie:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%jar   is object jar&lt;br /&gt;
 ...&lt;br /&gt;
print %jar:pickCookie:shape:sides&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Inverse attribute methods===&lt;br /&gt;
Inverse attribute methods let you derive an enumeration &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; based on the value of one of&lt;br /&gt;
its &amp;lt;var&amp;gt;[[#The Enumeration block|Attributes]]&amp;lt;/var&amp;gt;. To do so, you declare an &amp;lt;code&amp;gt;inverse&amp;lt;/code&amp;gt; method at the end of an &amp;lt;var&amp;gt;Attribute&amp;lt;/var&amp;gt; declaration, then you invoke the method, as is shown with the &amp;lt;code&amp;gt;fromOz&amp;lt;/code&amp;gt; method in this example: &lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration coffee                                                      &lt;br /&gt;
    public&lt;br /&gt;
       attribute oz is float inverse fromOz   &lt;br /&gt;
&lt;br /&gt;
       value tall   (12) &lt;br /&gt;
       value grande (16) &lt;br /&gt;
       value venti  (20) &lt;br /&gt;
    end public   &lt;br /&gt;
end enumeration            &lt;br /&gt;
&lt;br /&gt;
%order is enumeration coffee &lt;br /&gt;
&lt;br /&gt;
%order = fromOz(16)   &lt;br /&gt;
Print %order&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The result is: &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;grande&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Usage notes====&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Inverse attribute calls throw an &amp;lt;var&amp;gt;[[InvalidValue class|InvalidValue]]&amp;lt;/var&amp;gt; exception if the given value cannot be inverted. &lt;br /&gt;
&amp;lt;li&amp;gt;Since the same attribute value may appear in more than one &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; specification,&lt;br /&gt;
inverse attribute calls are checked at compile time for such ambiguous&lt;br /&gt;
value parameters. If you try to invert an attribute value that has multiple possible inverses, &lt;br /&gt;
you receive &amp;lt;code&amp;gt;MSIR.1029: Attribute error: Duplicate values specified for &lt;br /&gt;
invertible attribute&amp;lt;/code&amp;gt; when you attempt to compile the offending enumeration.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automatic methods===&lt;br /&gt;
Several methods are automatically provided for &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; enumeration&lt;br /&gt;
classes.&lt;br /&gt;
Some of these are identical to common methods available in most system&lt;br /&gt;
enumerations.&lt;br /&gt;
These methods are:&lt;br /&gt;
&amp;lt;table class=&amp;quot;thJustBold&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Copy&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Performs a &amp;amp;ldquo;copy&amp;amp;rdquo; of the enumeration value. Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]]. As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an enumeration variable, and the presence of these methods simply makes the copyability of enumeration variables explicit.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;DeepCopy&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Performs a &amp;amp;ldquo;copy&amp;amp;rdquo; of the enumeration value. Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]]. As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Or&amp;lt;/var&amp;gt; DeepCopy of an enumeration variable, and the presence of these methods simply makes the copyability of enumeration variables explicit.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;FromOrdinal&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This shared method is the inverse of the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method and converts an ordinal number to an enumeration value. The class specified in the shared method invocation determines the class of the result enumeration value.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
This method was introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;[[Sirius Mods]]&amp;lt;/var&amp;gt; Version 8.1.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;NumberOfValues&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This shared method returns the number of values in the enumeration class. The class specified in the shared method invocation determines the class whose value count is returned.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
This method was introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;[[Sirius Mods]]&amp;lt;/var&amp;gt; Version 8.1.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Ordinal&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Returns the ordinal position of the &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause associated with the value of the enumeration. For example, if an enumeration was declared as follows:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shot&lt;br /&gt;
   public&lt;br /&gt;
      value rock&lt;br /&gt;
      value paper&lt;br /&gt;
      value scissors&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The ordinal for a value of &amp;lt;var&amp;gt;Rock&amp;lt;/var&amp;gt; is 1, for &amp;lt;var&amp;gt;Paper&amp;lt;/var&amp;gt; 2, and &amp;lt;var&amp;gt;Scissors&amp;lt;/var&amp;gt; 3.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block, as described below.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;ToString&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Returns a string representation of the enumeration value.&lt;br /&gt;
The value returned uses the same case for the characters as was used on the &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declaration.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Using the Ordinal method====&lt;br /&gt;
The &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method, especially, bears further discussion.&lt;br /&gt;
It can be very useful in writing enumeration methods, especially in&lt;br /&gt;
conjunction with the &amp;lt;var&amp;gt;Jump&amp;lt;/var&amp;gt; statement.&lt;br /&gt;
For example, the &amp;lt;code&amp;gt;Sides&amp;lt;/code&amp;gt; method in the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration above could have been&lt;br /&gt;
written like:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;function sides is float&lt;br /&gt;
   jump to (three, four, four, four, four, five, none) %this:ordinal&lt;br /&gt;
   three: return 3&lt;br /&gt;
   four:  return 4&lt;br /&gt;
   five:  return 5&lt;br /&gt;
   none:  return 0&lt;br /&gt;
end function&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
While this might justifiably be disparaged as questionable programming technique,&lt;br /&gt;
it &#039;&#039;&#039;is&#039;&#039;&#039; very efficient and simple.&lt;br /&gt;
 &lt;br /&gt;
One disadvantage of such a technique is that the code is now highly&lt;br /&gt;
dependent on the order of the value declarations.&lt;br /&gt;
This means that it becomes difficult to rearrange the value declarations,&lt;br /&gt;
or to insert one into the list after there is code that uses the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt;&lt;br /&gt;
method on an enumeration class.&lt;br /&gt;
For this reason, the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method behaves like a private method, by&lt;br /&gt;
default.&lt;br /&gt;
That is, it is only available to methods inside the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; class&lt;br /&gt;
block.&lt;br /&gt;
 &lt;br /&gt;
One use of the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method that you might want to make public occurs&lt;br /&gt;
when the enumeration values have a natural ordering.&lt;br /&gt;
Consider, for example, the following enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration volume&lt;br /&gt;
   public&lt;br /&gt;
      value low&lt;br /&gt;
      value medium&lt;br /&gt;
      value high&lt;br /&gt;
      value deafening&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
With such an enumeration, one might want to use an enumeration value&#039;s&lt;br /&gt;
ordinality in comparisons.&lt;br /&gt;
To allow this to be done, the &amp;lt;var&amp;gt;Allow Ordinal&amp;lt;/var&amp;gt; directive must be placed in&lt;br /&gt;
the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block of the enumeration definition:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration volume&lt;br /&gt;
   public&lt;br /&gt;
      allow ordinal&lt;br /&gt;
      value low&lt;br /&gt;
      value medium&lt;br /&gt;
      value high&lt;br /&gt;
      value deafening&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Then, code like the following can be used outside the class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%leftSpeakerVolume  is enumeration volume&lt;br /&gt;
%rightSpeakerVolume is enumeration volume&lt;br /&gt;
 ...&lt;br /&gt;
if %leftSpeakerVolume:ordinal gt -&lt;br /&gt;
   %rightSpeakerVolume:ordinal then&lt;br /&gt;
   ...&lt;br /&gt;
end if&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Of course, the same effect could be achieved by adding a different method&lt;br /&gt;
to the enumeration, called perhaps &amp;lt;code&amp;gt;Level&amp;lt;/code&amp;gt;, that returned a non-ordinal value&lt;br /&gt;
that could still be used for comparisons:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%leftSpeakerVolume  is enumeration volume&lt;br /&gt;
%rightSpeakerVolume is enumeration volume&lt;br /&gt;
 ...&lt;br /&gt;
if %leftSpeakerVolume:level gt -&lt;br /&gt;
   %rightSpeakerVolume:level then&lt;br /&gt;
   ...&lt;br /&gt;
end if&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The advantage of this approach is that a non-ordinal value is less likely&lt;br /&gt;
to be misused for computed jumps, and the levels leave space to add values&lt;br /&gt;
associated with new enumeration values.&lt;br /&gt;
Another approach that avoids exposing the ordinal values of an&lt;br /&gt;
enumeration is to provide a comparison method to compare two enumeration&lt;br /&gt;
values.&lt;br /&gt;
&lt;br /&gt;
====Using the FromOrdinal and NumberOfValues methods====&lt;br /&gt;
The &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; methods were introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 8.1.&lt;br /&gt;
&lt;br /&gt;
These two methods make it easy to enumerate all the values in an enumeration class without having to maintain code that has a list of all the values. Because these methods could be used to build an equivalent to the automatic &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method, they require &amp;lt;var&amp;gt;Allow Ordinal&amp;lt;/var&amp;gt; to be set in the enumeration class against which they are used (see example below).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method is a [[Shared_class_members|shared method]] and has a single input argument: the ordinal number of the value to which to set the target enumeration variable. For example, if one has a &amp;lt;var&amp;gt;Stooge&amp;lt;/var&amp;gt; enmeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration stooge&lt;br /&gt;
   public&lt;br /&gt;
      value moe&lt;br /&gt;
      value larry&lt;br /&gt;
      value curly&lt;br /&gt;
      value shemp&lt;br /&gt;
      allow ordinal&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
then the following sequence:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite is enumeration stooge&lt;br /&gt;
%favorite = %(stooge):fromOrdinal(3)&lt;br /&gt;
printText {~=%favorite}&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
would print:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite=curly&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
If an invalid ordinal number is specified as input to the &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method, an &amp;lt;var&amp;gt;[[InvalidValue_class|InvalidValue]]&amp;lt;/var&amp;gt; exception is thrown. For example, the following:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite = %(stooge):fromOrdinal(-5)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
would result in the following request canceling error message:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;MSIR.0750: Class Stooge, function FromOrdinal: InvalidValue exception: -5 is not -&lt;br /&gt;
a valid ordinal number for class Stooge ...&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
You can catch such an exception to produce a list of all values in an enumeration class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;for %i from 1 to 99999999&lt;br /&gt;
   try printText {%(stooge):fromOrdinal(%i)}&lt;br /&gt;
   catch invalidValue; loop end&lt;br /&gt;
   end try&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This outputs:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;moe&lt;br /&gt;
larry&lt;br /&gt;
curly&lt;br /&gt;
shemp&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; automatic method for enumerations lets you do this a little more tidily:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;for %i from 1 to %(stooge):numberOfValues&lt;br /&gt;
   printText {%(stooge):fromOrdinal(%i)}&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; method has no parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; can be used to build an [[Arraylist_class|Arraylist]] that contains one item for each value in the enumeration class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%stoogeValues    is arraylist of enumeration stooge&lt;br /&gt;
 ...&lt;br /&gt;
%stoogeValues = new&lt;br /&gt;
for %i from 1 to %(stooge):numberOfValues&lt;br /&gt;
   %stoogeValues:add(%(stooge):fromOrdinal(%i))&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
One advantage of having such an &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; is that it can easily be sorted or searched. For example, the following displays the stooge values sorted in ascending character order:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%stoogevalues:[[SortNew_(GenericNamedArraylist_function)|sortNew]](ascending(toString)):print&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This displays:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;1: curly&lt;br /&gt;
2: larry&lt;br /&gt;
3: moe&lt;br /&gt;
4: shemp&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[Object oriented programming in SOUL]]&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:SOUL object-oriented programming topics]]&lt;/div&gt;</summary>
		<author><name>NMichell</name></author>
	</entry>
	<entry>
		<id>https://m204wiki.rocketsoftware.com/index.php?title=Enumerations&amp;diff=67593</id>
		<title>Enumerations</title>
		<link rel="alternate" type="text/html" href="https://m204wiki.rocketsoftware.com/index.php?title=Enumerations&amp;diff=67593"/>
		<updated>2014-02-24T02:22:23Z</updated>

		<summary type="html">&lt;p&gt;NMichell: Undo revision 67592 by NMichell (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Enumerations --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Objects may have properties that can have relatively few&lt;br /&gt;
values, such as True or False; Yes, No, or Maybe; Red, Green,&lt;br /&gt;
or Blue; or Small, Medium, Large, SuperSize.&lt;br /&gt;
These properties could be defined with a string datatype, in which case&lt;br /&gt;
they would be set to values like &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;.&lt;br /&gt;
Or they could be&lt;br /&gt;
defined with a numeric datatype like &amp;lt;var&amp;gt;Float&amp;lt;/var&amp;gt;, in which case they would&lt;br /&gt;
be set to values like &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
Both of these options are unappealing:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Using strings ties you to a particular case-sensitive representation&lt;br /&gt;
of the values.&lt;br /&gt;
&amp;lt;li&amp;gt;Using numbers makes the code unclear, as the meaning of, say, 2 is not&lt;br /&gt;
readily apparent.&lt;br /&gt;
&amp;lt;li&amp;gt;Neither strings nor numbers provide any compile-time validation of values.&lt;br /&gt;
That is, if the value of a property can be either &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;,&lt;br /&gt;
the compiler will allow the property to be set to &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt;,&lt;br /&gt;
or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;, or anything else, for that matter.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The special type of class called &#039;&#039;&#039;enumerations&#039;&#039;&#039;&lt;br /&gt;
solves these problems.&lt;br /&gt;
An enumeration class doesn&#039;t actually describe a set of objects but a set of&lt;br /&gt;
values or, more specifically, names for a set of values.&lt;br /&gt;
Since values are syntactically nouns, as are objects, enumeration handling is very&lt;br /&gt;
similar to object handling.&lt;br /&gt;
&amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; supports &#039;&#039;&#039;system enumerations&#039;&#039;&#039; (pre-defined&lt;br /&gt;
in the &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Model 204&amp;lt;/var&amp;gt; nucleus) as well as&lt;br /&gt;
&#039;&#039;&#039;user enumerations&#039;&#039;&#039; (defined within a &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; request.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Declaring enumeration variables== &lt;br /&gt;
Enumeration variables are declared very much like objects:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Enumeration&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;className&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;Initial&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration is so heavily used that the keyword&lt;br /&gt;
&amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; is optional for &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration variables:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Boolean&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;Initial&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%myAim   is boolean&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
An &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; variable, like an &amp;lt;var&amp;gt;Object&amp;lt;/var&amp;gt; variable can be null;&lt;br /&gt;
in fact this the the default initial value for all enumeration variables.&lt;br /&gt;
This means that certain operations on enumeration variables can result&lt;br /&gt;
in null-pointer reference errors.&lt;br /&gt;
It also means that, in some sense, all enumerations contain a special value&lt;br /&gt;
of &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; (though &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; behaves somewhat differently from other values).&lt;br /&gt;
This means that caution should be used for inequality tests on enumeration&lt;br /&gt;
variables as a null will satisfy an inequality test.&lt;br /&gt;
 &lt;br /&gt;
Enumeration variables, including &amp;lt;var&amp;gt;Booleans&amp;lt;/var&amp;gt;, can have a&lt;br /&gt;
compile-time initial value as specified by an &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%myAim   is boolean initial(true)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
Such a clause can also be placed on variables in a class &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt;, or&lt;br /&gt;
&amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; block:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class alison&lt;br /&gt;
  public&lt;br /&gt;
     variable myaim   is boolean initial(true)&lt;br /&gt;
     ...&lt;br /&gt;
  end public&lt;br /&gt;
  ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
As with other variable types, an &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause in a &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; block&lt;br /&gt;
sets the initial value for the variable when the containing object is&lt;br /&gt;
instantiated.&lt;br /&gt;
 &lt;br /&gt;
The sections that follow describe how to use enumerations, including the methods&lt;br /&gt;
that may be applied to them.&lt;br /&gt;
Most of the individual enumeration classes are documented elsewhere: in the&lt;br /&gt;
context of the (typically one) system class method&lt;br /&gt;
that uses the enumeration.&lt;br /&gt;
&lt;br /&gt;
==Using enumerations==&lt;br /&gt;
An explicit &amp;lt;var&amp;gt;New&amp;lt;/var&amp;gt; method is &#039;&#039;&#039;not&#039;&#039;&#039; allowed for enumeration variables.&lt;br /&gt;
Instead, they must be set from the possible values for the enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = %(boolean):true&lt;br /&gt;
 ...&lt;br /&gt;
%well = %(boolean):false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values are similar to shared properties of an object class and,&lt;br /&gt;
as with other shared properties, an enumeration variable can be used instead&lt;br /&gt;
of the class name to reference the shared properties:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = %well:true&lt;br /&gt;
 ...&lt;br /&gt;
%well = %well:false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Or, because the class can be inferred from the target,&lt;br /&gt;
enumerations can be set using just the value name:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = true&lt;br /&gt;
 ...&lt;br /&gt;
%well = false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
You can also use just the value name&lt;br /&gt;
when a method parameter is an enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class customer&lt;br /&gt;
   public&lt;br /&gt;
      subroutine setActive(%active is enumeration boolean)&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer  is object customer&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer:setActive(false)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Often, though, an enumeration will be a property rather than a&lt;br /&gt;
parameter.&lt;br /&gt;
The previous example would probably be recast as:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class customer&lt;br /&gt;
   public&lt;br /&gt;
      property active is enumeration boolean&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer  is object customer&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer:active = false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
System enumerations&lt;br /&gt;
can be declared with an explicit &amp;quot;system&amp;quot; on their declaration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration system:boolean&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumerations have a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method that returns the&lt;br /&gt;
string form of a value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 &lt;br /&gt;
%active = true&lt;br /&gt;
 &lt;br /&gt;
print %active:toString&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;imp2str&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;!-- Prior to &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.3 --&amp;gt;&lt;br /&gt;
Explicitly calling the &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method was formerly required to&lt;br /&gt;
display the string form of an enumeration value, and simply&lt;br /&gt;
specifying &amp;lt;code&amp;gt;print %active&amp;lt;/code&amp;gt; in the example above was an error,&lt;br /&gt;
because &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; is an object, not a string. &lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
However, now that explicitly specifying&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is optional, a statement like &amp;lt;code&amp;gt;print %active&amp;lt;/code&amp;gt;&lt;br /&gt;
automatically implies &amp;lt;code&amp;gt;print %active:toString&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is described further in [[#Calling ToString implicitly|Calling ToString implicitly]], below. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enumerations can also have other methods.&lt;br /&gt;
One class of such methods are &amp;quot;Is&amp;quot; methods that return&lt;br /&gt;
&amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; depending on whether the method has a particular&lt;br /&gt;
value.&lt;br /&gt;
 &lt;br /&gt;
For example, the following method tests if&lt;br /&gt;
the value of &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
if %active:isTrue then&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
This is almost exactly equivalent to the following:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
if %active eq true then&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The one difference between the two forms is that the former would cause&lt;br /&gt;
a null-pointer-reference request cancellation if &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; had never&lt;br /&gt;
been set, while the latter would simply evaluate &amp;lt;code&amp;gt;%active eq true&amp;lt;/code&amp;gt;&lt;br /&gt;
as false, since a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; value is not equal to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
There is an alternative to using these &amp;lt;var&amp;gt;Is&amp;lt;/var&amp;gt; methods for &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumerations&lt;br /&gt;
in the context of an &amp;lt;var&amp;gt;If&amp;lt;/var&amp;gt; statement:&lt;br /&gt;
automatic conversion of&lt;br /&gt;
a &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;True&amp;lt;/var&amp;gt; to a 1, and of a &amp;lt;var&amp;gt;False&amp;lt;/var&amp;gt; to a 0.&lt;br /&gt;
See [[#Using Boolean enumerations|Using Boolean enumerations]]. &amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
It is possible to use enumerations without ever declaring a variable&lt;br /&gt;
with that enumeration.&lt;br /&gt;
For example, one can set the &amp;lt;var&amp;gt;UseDefault&amp;lt;/var&amp;gt; property of a&lt;br /&gt;
&amp;lt;var&amp;gt;[[NamedArraylist class|NamedArraylist]]&amp;lt;/var&amp;gt; by just using the enumeration value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%description is collection NamedArraylist of string len 64&lt;br /&gt;
  ...&lt;br /&gt;
%description:useDefault = true&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Common enumeration methods==&lt;br /&gt;
The methods listed below are available to all system enumerations. The individual method descriptions follow.&lt;br /&gt;
&amp;lt;ul class=&amp;quot;nobul&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#Copy function|Copy]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#DeepCopy function|DeepCopy]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#FromString function|FromString]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#ToString property|ToString]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[#Using Boolean enumerations|versatile]] &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration has additional methods available.&lt;br /&gt;
&lt;br /&gt;
===Copy function===&lt;br /&gt;
This function returns an exact copy of the method object.&lt;br /&gt;
It is identical to the &amp;lt;var&amp;gt;[[#DeepCopy function|DeepCopy]]&amp;lt;/var&amp;gt; method.&lt;br /&gt;
Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no&lt;br /&gt;
different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]].&lt;br /&gt;
As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an&lt;br /&gt;
enumeration variable, and the presence of these methods simply&lt;br /&gt;
makes the copyability of enumeration variables explicit.&lt;br /&gt;
&lt;br /&gt;
====Copy syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%cop&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:Copy&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%cop&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable to contain the copy of &#039;&#039;enum&#039;&#039;. &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;%cop&amp;lt;/var&amp;gt; does not have to be [[XmlDoc API#XmlDoc states|empty]].&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The method object (&amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;) may be &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt;.&lt;br /&gt;
The output of a copy of a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object is a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
===DeepCopy function===&lt;br /&gt;
This function returns an exact copy of the method object.&lt;br /&gt;
It is identical to the &amp;lt;var&amp;gt;[[#Copy function|Copy]]&amp;lt;/var&amp;gt; method.&lt;br /&gt;
Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no&lt;br /&gt;
different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]].&lt;br /&gt;
As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an&lt;br /&gt;
enumeration variable, and the presence of these methods simply&lt;br /&gt;
makes the copyability of enumeration variables explicit.&lt;br /&gt;
&lt;br /&gt;
====DeepCopy syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%dcop&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:DeepCopy&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%dcop&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable to contain the deep copy of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;. &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;%dcop&amp;lt;/var&amp;gt; does not have to be [[XmlDoc API#XmlDoc states|empty]].&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The method object (&amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;) may be &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt;.&lt;br /&gt;
The output of a deep copy of a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object is a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
===FromString function===&lt;br /&gt;
&amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; is a [[Notation conventions for methods#Shared methods|shared]] function that converts a string argument into a value of the specified enumeration type.&lt;br /&gt;
This is the opposite of the enumeration &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method, which converts an enumeration value to its &amp;lt;var&amp;gt;String&amp;lt;/var&amp;gt; representation.&lt;br /&gt;
&amp;lt;!-- &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; is available as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; Version 7.8. --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====FromString syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%enum&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;= [%(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enumType&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;):]&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;FromString(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;string&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or expression.  &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;&amp;lt;var class=&amp;quot;nobr&amp;quot;&amp;gt;%(&amp;lt;i&amp;gt;enumType&amp;lt;/i&amp;gt;)&amp;lt;/var&amp;gt; &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This explicit specification of the enumeration type in parentheses denotes a [[Object variables#Virtual Constructor methods|virtual constructor]]. See [[#Usage notes|&amp;quot;Usage notes&amp;quot;]], below, for more information about invoking this function. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;string&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;A [[Longstrings|longstring]] variable that is assigned the current string value of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Usage Notes====&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;As an example, consider the following user-defined enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration Animal&lt;br /&gt;
    public&lt;br /&gt;
      value cat&lt;br /&gt;
      value dog&lt;br /&gt;
      value gecko&lt;br /&gt;
      value parrot&lt;br /&gt;
    end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can populate an &amp;lt;code&amp;gt;Animal&amp;lt;/code&amp;gt; enumeration variable with one of the &amp;lt;code&amp;gt;Animal&amp;lt;/code&amp;gt; enumeration values by making a call to &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt;:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet is enumeration animal&lt;br /&gt;
%pet = fromString(&#039;gecko&#039;)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The result of a &amp;lt;var&amp;gt;Print&amp;lt;/var&amp;gt; of &amp;lt;code&amp;gt;%pet&amp;lt;/code&amp;gt; above is &amp;lt;code&amp;gt;gecko&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; In the method call, &amp;lt;code&amp;gt;fromString&amp;lt;/code&amp;gt; might but does &#039;&#039;&#039;not&#039;&#039;&#039; have to be preceded by &amp;lt;code&amp;gt;%(Animal):&amp;lt;/code&amp;gt; to identify the type of enumeration, because the type is determined from the result variable. You could also get the same result from invoking with an already defined enumeration variable, as in:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet = %pet:fromString(&#039;gecko&#039;)&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;li&amp;gt;Only strings that match a value of the particular enumeration type&lt;br /&gt;
can be converted. If a string cannot be converted to an enumeration&lt;br /&gt;
value, &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; throws an &amp;lt;var&amp;gt;[[InvalidValue class|Invalidvalue]]&amp;lt;/var&amp;gt; exception:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet = fromString(&#039;alien&#039;)&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;  1  CANCELLING REQUEST: MSIR.0750: Class Animal, function&lt;br /&gt;
FromString: InvalidValue exception: ALIEN is not a valid enumeration&lt;br /&gt;
value in line 84, procedure ENUM, file MYPROC&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ToString property===&lt;br /&gt;
This non-settable property examines an enumeration&lt;br /&gt;
and returns a printable or testable string representation of its value.&lt;br /&gt;
&lt;br /&gt;
====ToString syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%ls&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:ToString&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%ls&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;A [[Longstrings|longstring]] variable that is assigned the current string value of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;printenum&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
====Calling ToString implicitly====&lt;br /&gt;
&amp;lt;!-- As of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.3 --&amp;gt;To return a string representation of the value of a &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; system or user-defined enumeration, you can do either of the following:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Explicitly specify the &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Print (or audit) the value of an enumeration, and &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is implied,&lt;br /&gt;
as shown in the following example:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;begin&lt;br /&gt;
enumeration color&lt;br /&gt;
   public&lt;br /&gt;
      value red&lt;br /&gt;
      value white&lt;br /&gt;
      value blue&lt;br /&gt;
      value green&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
 &lt;br /&gt;
%x  is boolean initial(true)&lt;br /&gt;
%z  is enumeration color initial(blue)&lt;br /&gt;
%daem is object daemon&lt;br /&gt;
 &lt;br /&gt;
%daem = new&lt;br /&gt;
 &lt;br /&gt;
print %x with &#039; &#039; %z&lt;br /&gt;
[[PrintText statement|printText]] {~} = {%x}, {~} = {%z}&lt;br /&gt;
print %daem:haveDaemon&lt;br /&gt;
printText {~} = {%daem:haveDaemon}&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The &amp;lt;var&amp;gt;Print&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;PrintText&amp;lt;/var&amp;gt; statements above produce these results:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;True blue&lt;br /&gt;
%x = True, %z = blue&lt;br /&gt;
True&lt;br /&gt;
%daem:haveDaemon = True&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
In addition, the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; feature extends beyond enumerations:&lt;br /&gt;
upon any attempt to print or audit any object value, &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; will try to apply a&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method to the object.&lt;br /&gt;
If the object is an enumeration (as shown above) or is an&lt;br /&gt;
instance of a system or user-defined class that has a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method,&lt;br /&gt;
a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is implicitly&lt;br /&gt;
applied and the result is a successful print or audit of the object value.&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
For example, the user-defined class in the following request includes a&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method.&lt;br /&gt;
The request&#039;s &amp;lt;code&amp;gt;printText&amp;lt;/code&amp;gt; statement prints &amp;lt;code&amp;gt;%x = a=11, b=22&amp;lt;/code&amp;gt;. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;begin&lt;br /&gt;
class mumble&lt;br /&gt;
  public&lt;br /&gt;
    variable   a is float&lt;br /&gt;
    variable   b is float&lt;br /&gt;
    constructor new(%a is float nameRequired, %b is float)&lt;br /&gt;
    function tostring is longstring&lt;br /&gt;
  end public&lt;br /&gt;
  constructor new(%a  is float nameRequired, %b is float)&lt;br /&gt;
    %this:a = %a&lt;br /&gt;
    %this:b = %b&lt;br /&gt;
  end constructor&lt;br /&gt;
  function tostring is longstring&lt;br /&gt;
    return &#039;a=&#039; with %a with &#039;, b=&#039; with %b&lt;br /&gt;
  end function&lt;br /&gt;
end class&lt;br /&gt;
 &lt;br /&gt;
   %x   is object mumble&lt;br /&gt;
   %x = new(a=11, b=22)&lt;br /&gt;
   printText {~} = {%x}&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
If the object you try to print or audit directly is not an enumeration or is&lt;br /&gt;
an instance of a class that does not have a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method (system or&lt;br /&gt;
user-written), you receive a compilation error.&lt;br /&gt;
For example, if &amp;lt;code&amp;gt;%sl&amp;lt;/code&amp;gt; is a &amp;lt;var&amp;gt;Stringlist&amp;lt;/var&amp;gt; object, no user &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method exists,&lt;br /&gt;
and your request contains a &amp;lt;code&amp;gt;Print %sl&amp;lt;/code&amp;gt; statement, you get a message&lt;br /&gt;
like the following: &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;&amp;amp;#42;**  1  MSIR.0733: Member TOSTRING not found in class STRINGLIST&lt;br /&gt;
  print %sl&lt;br /&gt;
  (FILE = JALWORK, PROCEDURE = FOO, LINE = 28)&lt;br /&gt;
&amp;amp;#42;**  M204.1042: COMPILATION ERRORS&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
Finally, if the object you try to print directly is a &amp;lt;var&amp;gt;Unicode&amp;lt;/var&amp;gt; variable,&lt;br /&gt;
&amp;lt;!-- under &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.6 and higher --&amp;gt;&lt;br /&gt;
the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method returns an EBCDIC character-encoded value for&lt;br /&gt;
Unicode characters that do not translate to EBCDIC.&lt;br /&gt;
This is described further in [[Unicode#Implicit Unicode conversions|&amp;quot;Implicit Unicode conversions&amp;quot;]]. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Boolean enumeration==&lt;br /&gt;
The [[Boolean enumeration]] is probably the most commonly used, and so the most important enumeration class. Because of its importance, it is treated specially by &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt;, and is a topic unto itself.&lt;br /&gt;
&lt;br /&gt;
==User enumerations==&lt;br /&gt;
While there are a wide variety of system enumerations that can be useful in&lt;br /&gt;
many contexts (especially the &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration), it is&lt;br /&gt;
also possible to define user enumerations in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt;.&lt;br /&gt;
This is done via the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; statement/block, which is very similar to the&lt;br /&gt;
&amp;lt;var&amp;gt;Class&amp;lt;/var&amp;gt; statement/block (as in [[Classes and Objects|&amp;quot;Classes and objects&amp;quot;]]).&lt;br /&gt;
&lt;br /&gt;
===The Enumeration block===&lt;br /&gt;
The &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; block can contain &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt;, and &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; blocks, just like any other class.&lt;br /&gt;
However, because enumeration classes don&#039;t really describe objects, there&lt;br /&gt;
can be no instance variables.&lt;br /&gt;
That is, the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; blocks cannot contain &amp;lt;var&amp;gt;Variable&amp;lt;/var&amp;gt; declarations.&lt;br /&gt;
 &lt;br /&gt;
Instead, the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block must contain one or more &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declarations&lt;br /&gt;
whose syntax is:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Value&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;attribute&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Each value declared by a &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declaration becomes one of the values of the enumeration. &lt;br /&gt;
&lt;br /&gt;
One or more &#039;&#039;&#039;attributes&#039;&#039;&#039; (a constant datum of type &amp;lt;var&amp;gt;String&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Float&amp;lt;/var&amp;gt;, or &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt;) can be attached to an enumeration value. &amp;lt;!-- (as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.8) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
No values or attributes are allowed in the &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; blocks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The value in a &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause is unusual in that the case (lower or upper)&lt;br /&gt;
of the characters in its value are saved and used in the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method. The same is true for the values in an &amp;lt;var&amp;gt;Attribute&amp;lt;/var&amp;gt; clause. &amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The following is an example of a simple enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shape&lt;br /&gt;
   public&lt;br /&gt;
      attribute code is string &lt;br /&gt;
&lt;br /&gt;
      value triangle      (code=&#039;31&#039;)&lt;br /&gt;
      value square        (code=&#039;44&#039;)&lt;br /&gt;
      value rhombus       (code=&#039;42&#039;)&lt;br /&gt;
      value rectangle     (code=&#039;41&#039;)&lt;br /&gt;
      value quadrilateral (code=&#039;40&#039;)&lt;br /&gt;
      value pentagon      (code=&#039;50&#039;)&lt;br /&gt;
      value circle        (code=&#039;01&#039;)&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All attributes must be declared before any value is declared. In a given &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;A specification for each attribute must be explicitly present.  &lt;br /&gt;
&amp;lt;li&amp;gt;An attribute may be specified by name or by position; and like a method [[Methods#Named_parameters|named parameter]], an attribute specified with its name may not precede an attribute specified only by position.&lt;br /&gt;
&amp;lt;li&amp;gt;An attribute name may not repeat.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
Just as for &amp;lt;var&amp;gt;Class&amp;lt;/var&amp;gt; blocks, &amp;lt;!-- as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.3 --&amp;gt;&lt;br /&gt;
an &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; block you declare inside a method or complex subroutine&lt;br /&gt;
must be preceded by the keyword &amp;lt;var&amp;gt;Local&amp;lt;/var&amp;gt;.&lt;br /&gt;
For more information about locally-scoped classes and enumerations,&lt;br /&gt;
see [[Local and Common entities#Local classes, enumerations, and structures|&amp;quot;Local classes, enumerations, and structures&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
===Using user enumerations=== &lt;br /&gt;
You can use user-defined enumerations just like system enumerations.&lt;br /&gt;
That is, variables are declared with the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; keyword and class name:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape is enumeration shape&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values may be assigned to an enumeration variable:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape = circle&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Such a variable may be printed (&amp;lt;code&amp;gt;Print %cookieShape&amp;lt;/code&amp;gt;), and it may be used to access an enumeration attribute:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;Print %cookieShape:code&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More commonly, enumerations may be used as method parameters:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class cookie&lt;br /&gt;
   ...&lt;br /&gt;
   subroutine cut(%shape is enumeration shape)&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And, typically, literal values are used as the arguments when invoking&lt;br /&gt;
such a method:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%biscuit   is object cookie&lt;br /&gt;
 ...&lt;br /&gt;
%biscuit:cut(pentagon)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values are not strings, so they are case insensitive.&lt;br /&gt;
While the class of an enumeration value can almost always be determined&lt;br /&gt;
from context, the class name can always be explicitly specified for a&lt;br /&gt;
value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape = %(shape):circle&lt;br /&gt;
 ...&lt;br /&gt;
%biscuit:cut(%(shape):pentagon)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Like system enumerations, user enumeration variables can be in a state where&lt;br /&gt;
they have no value, that is, they can be null.&lt;br /&gt;
In fact, that is the initial value of any enumeration variable.&lt;br /&gt;
&lt;br /&gt;
As with system enumerations, you can change the default initial value&lt;br /&gt;
with the &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause on the variable declaration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Enumeration&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enumerationName&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Initial&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can set the default initial value for local variables:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cutout is enumeration shape initial(square)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And you can set it for variables in class blocks:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class cookie&lt;br /&gt;
   public&lt;br /&gt;
      variable shape is enumeration shape initial(round)&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Of course, instance-specific (non-&amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt;) initial values are set&lt;br /&gt;
for each instance of the class when it is created.&lt;br /&gt;
&lt;br /&gt;
===Enumeration methods===&lt;br /&gt;
Enumeration classes can also contain methods that operate on&lt;br /&gt;
or are related to the enumeration values.&lt;br /&gt;
For example, the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration can have a method that returns the number&lt;br /&gt;
of sides in a shape:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shape&lt;br /&gt;
   public&lt;br /&gt;
      ...&lt;br /&gt;
      function sides is float&lt;br /&gt;
   end public&lt;br /&gt;
   function sides is float&lt;br /&gt;
      if %this eq circle then&lt;br /&gt;
         return 0&lt;br /&gt;
      end if&lt;br /&gt;
      if %this eq triangle then&lt;br /&gt;
         return 3&lt;br /&gt;
      end if&lt;br /&gt;
      ...&lt;br /&gt;
   end function&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
As this example illustrates, the implicit &amp;lt;code&amp;gt;%this&amp;lt;/code&amp;gt; variable for enumeration&lt;br /&gt;
methods contains not an object reference but an enumeration value.&lt;br /&gt;
 &lt;br /&gt;
Enumeration methods can be applied to enumeration values as well as enumeration variables.&lt;br /&gt;
This is one case, however, where the enumeration value &#039;&#039;&#039;must&#039;&#039;&#039;&lt;br /&gt;
be qualified with the class name, because it appears in a context where&lt;br /&gt;
the class cannot be determined otherwise:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;print %(shape):rhombus:sides&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And, as with objects, an enumeration method could be applied to the output&lt;br /&gt;
of another method that returns an enumeration value.&lt;br /&gt;
For example, if the &amp;lt;code&amp;gt;PickCookie&amp;lt;/code&amp;gt; method of the &amp;lt;code&amp;gt;Jar&amp;lt;/code&amp;gt; class returns a&lt;br /&gt;
&amp;lt;code&amp;gt;Cookie&amp;lt;/code&amp;gt; object, and the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; method of the &amp;lt;code&amp;gt;Cookie&amp;lt;/code&amp;gt; class returns a&lt;br /&gt;
&amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration value, the following prints the number of sides of&lt;br /&gt;
a picked cookie:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%jar   is object jar&lt;br /&gt;
 ...&lt;br /&gt;
print %jar:pickCookie:shape:sides&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Inverse attribute methods===&lt;br /&gt;
Inverse attribute methods let you derive an enumeration &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; based on the value of one of&lt;br /&gt;
its &amp;lt;var&amp;gt;[[#The Enumeration block|Attributes]]&amp;lt;/var&amp;gt;. To do so, you declare an &amp;lt;code&amp;gt;inverse&amp;lt;/code&amp;gt; method at the end of an &amp;lt;var&amp;gt;Attribute&amp;lt;/var&amp;gt; declaration, then you invoke the method, as is shown with the &amp;lt;code&amp;gt;fromOz&amp;lt;/code&amp;gt; method in this example: &lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration coffee                                                      &lt;br /&gt;
    public&lt;br /&gt;
       attribute oz is float inverse fromOz   &lt;br /&gt;
&lt;br /&gt;
       value tall   (12) &lt;br /&gt;
       value grande (16) &lt;br /&gt;
       value venti  (20) &lt;br /&gt;
    end public   &lt;br /&gt;
end enumeration            &lt;br /&gt;
&lt;br /&gt;
%order is enumeration coffee &lt;br /&gt;
&lt;br /&gt;
%order = fromOz(16)   &lt;br /&gt;
Print %order&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The result is: &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;grande&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Usage notes====&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Inverse attribute calls throw an &amp;lt;var&amp;gt;[[InvalidValue class|InvalidValue]]&amp;lt;/var&amp;gt; exception if the given value cannot be inverted. &lt;br /&gt;
&amp;lt;li&amp;gt;Since the same attribute value may appear in more than one &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; specification,&lt;br /&gt;
inverse attribute calls are checked at compile time for such ambiguous&lt;br /&gt;
value parameters. If you try to invert an attribute value that has multiple possible inverses, &lt;br /&gt;
you receive &amp;lt;code&amp;gt;MSIR.1029: Attribute error: Duplicate values specified for &lt;br /&gt;
invertible attribute&amp;lt;/code&amp;gt; when you attempt to compile the offending enumeration.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automatic methods===&lt;br /&gt;
Several methods are automatically provided for &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; enumeration&lt;br /&gt;
classes.&lt;br /&gt;
Some of these are identical to common methods available in most system&lt;br /&gt;
enumerations.&lt;br /&gt;
These methods are:&lt;br /&gt;
&amp;lt;table class=&amp;quot;thJustBold&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Copy&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Performs a &amp;amp;ldquo;copy&amp;amp;rdquo; of the enumeration value. Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]]. As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an enumeration variable, and the presence of these methods simply makes the copyability of enumeration variables explicit.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;DeepCopy&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Performs a &amp;amp;ldquo;copy&amp;amp;rdquo; of the enumeration value. Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]]. As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Or&amp;lt;/var&amp;gt; DeepCopy of an enumeration variable, and the presence of these methods simply makes the copyability of enumeration variables explicit.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;FromOrdinal&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This shared method is the inverse of the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method and converts an ordinal number to an enumeration value. The class specified in the shared method invocation determines the class of the result enumeration value.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
This method was introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;[[Sirius Mods]]&amp;lt;/var&amp;gt; Version 8.1.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;NumberOfValues&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This shared method returns the number of values in the enumeration class. The class specified in the shared method invocation determines the class whose value count is returned.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
This method was introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;[[Sirius Mods]]&amp;lt;/var&amp;gt; Version 8.1.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Ordinal&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Returns the ordinal position of the &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause associated with the value of the enumeration. For example, if an enumeration was declared as follows:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shot&lt;br /&gt;
   public&lt;br /&gt;
      value rock&lt;br /&gt;
      value paper&lt;br /&gt;
      value scissors&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The ordinal for a value of &amp;lt;var&amp;gt;Rock&amp;lt;/var&amp;gt; is 1, for &amp;lt;var&amp;gt;Paper&amp;lt;/var&amp;gt; 2, and &amp;lt;var&amp;gt;Scissors&amp;lt;/var&amp;gt; 3.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block, as described below.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;ToString&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Returns a string representation of the enumeration value.&lt;br /&gt;
The value returned uses the same case for the characters as was used on the &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declaration.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Using the Ordinal method====&lt;br /&gt;
The &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method, especially, bears further discussion.&lt;br /&gt;
It can be very useful in writing enumeration methods, especially in&lt;br /&gt;
conjunction with the &amp;lt;var&amp;gt;Jump&amp;lt;/var&amp;gt; statement.&lt;br /&gt;
For example, the &amp;lt;code&amp;gt;Sides&amp;lt;/code&amp;gt; method in the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration above could have been&lt;br /&gt;
written like:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;function sides is float&lt;br /&gt;
   jump to (three, four, four, four, four, five, none) %this:ordinal&lt;br /&gt;
   three: return 3&lt;br /&gt;
   four:  return 4&lt;br /&gt;
   five:  return 5&lt;br /&gt;
   none:  return 0&lt;br /&gt;
end function&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
While this might justifiably be disparaged as questionable programming technique,&lt;br /&gt;
it &#039;&#039;&#039;is&#039;&#039;&#039; very efficient and simple.&lt;br /&gt;
 &lt;br /&gt;
One disadvantage of such a technique is that the code is now highly&lt;br /&gt;
dependent on the order of the value declarations.&lt;br /&gt;
This means that it becomes difficult to rearrange the value declarations,&lt;br /&gt;
or to insert one into the list after there is code that uses the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt;&lt;br /&gt;
method on an enumeration class.&lt;br /&gt;
For this reason, the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method behaves like a private method, by&lt;br /&gt;
default.&lt;br /&gt;
That is, it is only available to methods inside the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; class&lt;br /&gt;
block.&lt;br /&gt;
 &lt;br /&gt;
One use of the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method that you might want to make public occurs&lt;br /&gt;
when the enumeration values have a natural ordering.&lt;br /&gt;
Consider, for example, the following enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration volume&lt;br /&gt;
   public&lt;br /&gt;
      value low&lt;br /&gt;
      value medium&lt;br /&gt;
      value high&lt;br /&gt;
      value deafening&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
With such an enumeration, one might want to use an enumeration value&#039;s&lt;br /&gt;
ordinality in comparisons.&lt;br /&gt;
To allow this to be done, the &amp;lt;var&amp;gt;Allow Ordinal&amp;lt;/var&amp;gt; directive must be placed in&lt;br /&gt;
the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block of the enumeration definition:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration volume&lt;br /&gt;
   public&lt;br /&gt;
      allow ordinal&lt;br /&gt;
      value low&lt;br /&gt;
      value medium&lt;br /&gt;
      value high&lt;br /&gt;
      value deafening&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Then, code like the following can be used outside the class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%leftSpeakerVolume  is enumeration volume&lt;br /&gt;
%rightSpeakerVolume is enumeration volume&lt;br /&gt;
 ...&lt;br /&gt;
if %leftSpeakerVolume:ordinal gt -&lt;br /&gt;
   %rightSpeakerVolume:ordinal then&lt;br /&gt;
   ...&lt;br /&gt;
end if&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Of course, the same effect could be achieved by adding a different method&lt;br /&gt;
to the enumeration, called perhaps &amp;lt;code&amp;gt;Level&amp;lt;/code&amp;gt;, that returned a non-ordinal value&lt;br /&gt;
that could still be used for comparisons:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%leftSpeakerVolume  is enumeration volume&lt;br /&gt;
%rightSpeakerVolume is enumeration volume&lt;br /&gt;
 ...&lt;br /&gt;
if %leftSpeakerVolume:level gt -&lt;br /&gt;
   %rightSpeakerVolume:level then&lt;br /&gt;
   ...&lt;br /&gt;
end if&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The advantage of this approach is that a non-ordinal value is less likely&lt;br /&gt;
to be misused for computed jumps, and the levels leave space to add values&lt;br /&gt;
associated with new enumeration values.&lt;br /&gt;
Another approach that avoids exposing the ordinal values of an&lt;br /&gt;
enumeration is to provide a comparison method to compare two enumeration&lt;br /&gt;
values.&lt;br /&gt;
&lt;br /&gt;
====Using the FromOrdinal and NumberOfValues methods====&lt;br /&gt;
The &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; methods were introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 8.1.&lt;br /&gt;
&lt;br /&gt;
These two methods make it easy to enumerate all the values in an enumeration class without having to maintain code that has a list of all the values. Because these methods could be used to build an equivalent to the automatic &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method, they require &amp;lt;var&amp;gt;Allow Ordinal&amp;lt;/var&amp;gt; to be set in the enumeration class against which they are used (see example below).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method is a [[Shared_class_members|shared method]] and has a single input argument: the ordinal number of the value to which to set the target enumeration variable. For example, if one has a &amp;lt;var&amp;gt;Stooge&amp;lt;/var&amp;gt; enmeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration stooge&lt;br /&gt;
   public&lt;br /&gt;
      value moe&lt;br /&gt;
      value larry&lt;br /&gt;
      value curly&lt;br /&gt;
      value shemp&lt;br /&gt;
      allow ordinal&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
then the following sequence:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite is enumeration stooge&lt;br /&gt;
%favorite = %(stooge):fromOrdinal(3)&lt;br /&gt;
printText {~=%favorite}&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
would print:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite=curly&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
If an invalid ordinal number is specified as input to the &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method, an &amp;lt;var&amp;gt;[[InvalidValue_class|InvalidValue]]&amp;lt;/var&amp;gt; exception is thrown. For example, the following:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite = %(stooge):fromOrdinal(-5)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
would result in the following request canceling error message:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;MSIR.0750: Class Stooge, function FromOrdinal: InvalidValue exception: -5 is not -&lt;br /&gt;
a valid ordinal number for class Stooge ...&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
You can catch such an exception to produce a list of all values in an enumeration class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;for %i from 1 to 99999999&lt;br /&gt;
   try printText {%(stooge):fromOrdinal(%i)}&lt;br /&gt;
   catch invalidValue; loop end&lt;br /&gt;
   end try&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This outputs:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;moe&lt;br /&gt;
larry&lt;br /&gt;
curly&lt;br /&gt;
shemp&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; automatic method for enumerations lets you do this a little more tidily:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;for %i from 1 to %(stooge):numberOfValues&lt;br /&gt;
   printText {%(stooge):fromOrdinal(%i)}&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; method has no parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; can be used to build an [[Arraylist_class|Arraylist]] that contains one item for each value in the enumeration class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%stoogeValues    is arraylist of enumeration stooge&lt;br /&gt;
 ...&lt;br /&gt;
%stoogeValues = new&lt;br /&gt;
for %i from 1 to %(stooge):numberOfValues&lt;br /&gt;
   %stoogeValues:add(%(stooge):fromOrdinal(%i))&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
One advantage of having such an &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; is that it can easily be sorted or searched. For example, the following displays the stooge values sorted in ascending character order:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%stoogevalues:[[SortNew_(GenericNamedArraylist_function)|sortNew]](ascending(toString)):print&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This displays:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;1: curly&lt;br /&gt;
2: larry&lt;br /&gt;
3: moe&lt;br /&gt;
4: shemp&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[Object oriented programming in SOUL]]&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:SOUL object-oriented programming topics]]&lt;/div&gt;</summary>
		<author><name>NMichell</name></author>
	</entry>
	<entry>
		<id>https://m204wiki.rocketsoftware.com/index.php?title=Enumerations&amp;diff=67592</id>
		<title>Enumerations</title>
		<link rel="alternate" type="text/html" href="https://m204wiki.rocketsoftware.com/index.php?title=Enumerations&amp;diff=67592"/>
		<updated>2014-02-24T02:19:03Z</updated>

		<summary type="html">&lt;p&gt;NMichell: Added &amp;lt;/P&amp;gt; just before &amp;quot;Using user enumerations&amp;quot;. Absence was causing &amp;quot;cookieShape is enumeration shape&amp;quot; to be shown in main text body.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Enumerations --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Objects may have properties that can have relatively few&lt;br /&gt;
values, such as True or False; Yes, No, or Maybe; Red, Green,&lt;br /&gt;
or Blue; or Small, Medium, Large, SuperSize.&lt;br /&gt;
These properties could be defined with a string datatype, in which case&lt;br /&gt;
they would be set to values like &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;.&lt;br /&gt;
Or they could be&lt;br /&gt;
defined with a numeric datatype like &amp;lt;var&amp;gt;Float&amp;lt;/var&amp;gt;, in which case they would&lt;br /&gt;
be set to values like &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
Both of these options are unappealing:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Using strings ties you to a particular case-sensitive representation&lt;br /&gt;
of the values.&lt;br /&gt;
&amp;lt;li&amp;gt;Using numbers makes the code unclear, as the meaning of, say, 2 is not&lt;br /&gt;
readily apparent.&lt;br /&gt;
&amp;lt;li&amp;gt;Neither strings nor numbers provide any compile-time validation of values.&lt;br /&gt;
That is, if the value of a property can be either &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;,&lt;br /&gt;
the compiler will allow the property to be set to &amp;lt;code&amp;gt;&#039;True&#039;&amp;lt;/code&amp;gt;,&lt;br /&gt;
or &amp;lt;code&amp;gt;&#039;False&#039;&amp;lt;/code&amp;gt;, or anything else, for that matter.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The special type of class called &#039;&#039;&#039;enumerations&#039;&#039;&#039;&lt;br /&gt;
solves these problems.&lt;br /&gt;
An enumeration class doesn&#039;t actually describe a set of objects but a set of&lt;br /&gt;
values or, more specifically, names for a set of values.&lt;br /&gt;
Since values are syntactically nouns, as are objects, enumeration handling is very&lt;br /&gt;
similar to object handling.&lt;br /&gt;
&amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; supports &#039;&#039;&#039;system enumerations&#039;&#039;&#039; (pre-defined&lt;br /&gt;
in the &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Model 204&amp;lt;/var&amp;gt; nucleus) as well as&lt;br /&gt;
&#039;&#039;&#039;user enumerations&#039;&#039;&#039; (defined within a &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; request.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Declaring enumeration variables== &lt;br /&gt;
Enumeration variables are declared very much like objects:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Enumeration&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;className&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;Initial&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration is so heavily used that the keyword&lt;br /&gt;
&amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; is optional for &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration variables:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Boolean&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;Initial&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%myAim   is boolean&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
An &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; variable, like an &amp;lt;var&amp;gt;Object&amp;lt;/var&amp;gt; variable can be null;&lt;br /&gt;
in fact this the the default initial value for all enumeration variables.&lt;br /&gt;
This means that certain operations on enumeration variables can result&lt;br /&gt;
in null-pointer reference errors.&lt;br /&gt;
It also means that, in some sense, all enumerations contain a special value&lt;br /&gt;
of &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; (though &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; behaves somewhat differently from other values).&lt;br /&gt;
This means that caution should be used for inequality tests on enumeration&lt;br /&gt;
variables as a null will satisfy an inequality test.&lt;br /&gt;
 &lt;br /&gt;
Enumeration variables, including &amp;lt;var&amp;gt;Booleans&amp;lt;/var&amp;gt;, can have a&lt;br /&gt;
compile-time initial value as specified by an &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%myAim   is boolean initial(true)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
Such a clause can also be placed on variables in a class &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt;, or&lt;br /&gt;
&amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; block:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class alison&lt;br /&gt;
  public&lt;br /&gt;
     variable myaim   is boolean initial(true)&lt;br /&gt;
     ...&lt;br /&gt;
  end public&lt;br /&gt;
  ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
As with other variable types, an &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause in a &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; block&lt;br /&gt;
sets the initial value for the variable when the containing object is&lt;br /&gt;
instantiated.&lt;br /&gt;
 &lt;br /&gt;
The sections that follow describe how to use enumerations, including the methods&lt;br /&gt;
that may be applied to them.&lt;br /&gt;
Most of the individual enumeration classes are documented elsewhere: in the&lt;br /&gt;
context of the (typically one) system class method&lt;br /&gt;
that uses the enumeration.&lt;br /&gt;
&lt;br /&gt;
==Using enumerations==&lt;br /&gt;
An explicit &amp;lt;var&amp;gt;New&amp;lt;/var&amp;gt; method is &#039;&#039;&#039;not&#039;&#039;&#039; allowed for enumeration variables.&lt;br /&gt;
Instead, they must be set from the possible values for the enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = %(boolean):true&lt;br /&gt;
 ...&lt;br /&gt;
%well = %(boolean):false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values are similar to shared properties of an object class and,&lt;br /&gt;
as with other shared properties, an enumeration variable can be used instead&lt;br /&gt;
of the class name to reference the shared properties:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = %well:true&lt;br /&gt;
 ...&lt;br /&gt;
%well = %well:false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Or, because the class can be inferred from the target,&lt;br /&gt;
enumerations can be set using just the value name:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%well  is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
%well = true&lt;br /&gt;
 ...&lt;br /&gt;
%well = false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
You can also use just the value name&lt;br /&gt;
when a method parameter is an enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class customer&lt;br /&gt;
   public&lt;br /&gt;
      subroutine setActive(%active is enumeration boolean)&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer  is object customer&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer:setActive(false)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Often, though, an enumeration will be a property rather than a&lt;br /&gt;
parameter.&lt;br /&gt;
The previous example would probably be recast as:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class customer&lt;br /&gt;
   public&lt;br /&gt;
      property active is enumeration boolean&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer  is object customer&lt;br /&gt;
 ...&lt;br /&gt;
%myCustomer:active = false&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
System enumerations&lt;br /&gt;
can be declared with an explicit &amp;quot;system&amp;quot; on their declaration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration system:boolean&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumerations have a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method that returns the&lt;br /&gt;
string form of a value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 &lt;br /&gt;
%active = true&lt;br /&gt;
 &lt;br /&gt;
print %active:toString&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;imp2str&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;!-- Prior to &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.3 --&amp;gt;&lt;br /&gt;
Explicitly calling the &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method was formerly required to&lt;br /&gt;
display the string form of an enumeration value, and simply&lt;br /&gt;
specifying &amp;lt;code&amp;gt;print %active&amp;lt;/code&amp;gt; in the example above was an error,&lt;br /&gt;
because &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; is an object, not a string. &lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
However, now that explicitly specifying&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is optional, a statement like &amp;lt;code&amp;gt;print %active&amp;lt;/code&amp;gt;&lt;br /&gt;
automatically implies &amp;lt;code&amp;gt;print %active:toString&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is described further in [[#Calling ToString implicitly|Calling ToString implicitly]], below. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enumerations can also have other methods.&lt;br /&gt;
One class of such methods are &amp;quot;Is&amp;quot; methods that return&lt;br /&gt;
&amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; depending on whether the method has a particular&lt;br /&gt;
value.&lt;br /&gt;
 &lt;br /&gt;
For example, the following method tests if&lt;br /&gt;
the value of &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
if %active:isTrue then&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
This is almost exactly equivalent to the following:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%active is enumeration boolean&lt;br /&gt;
 ...&lt;br /&gt;
if %active eq true then&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The one difference between the two forms is that the former would cause&lt;br /&gt;
a null-pointer-reference request cancellation if &amp;lt;code&amp;gt;%active&amp;lt;/code&amp;gt; had never&lt;br /&gt;
been set, while the latter would simply evaluate &amp;lt;code&amp;gt;%active eq true&amp;lt;/code&amp;gt;&lt;br /&gt;
as false, since a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; value is not equal to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
There is an alternative to using these &amp;lt;var&amp;gt;Is&amp;lt;/var&amp;gt; methods for &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumerations&lt;br /&gt;
in the context of an &amp;lt;var&amp;gt;If&amp;lt;/var&amp;gt; statement:&lt;br /&gt;
automatic conversion of&lt;br /&gt;
a &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;True&amp;lt;/var&amp;gt; to a 1, and of a &amp;lt;var&amp;gt;False&amp;lt;/var&amp;gt; to a 0.&lt;br /&gt;
See [[#Using Boolean enumerations|Using Boolean enumerations]]. &amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
It is possible to use enumerations without ever declaring a variable&lt;br /&gt;
with that enumeration.&lt;br /&gt;
For example, one can set the &amp;lt;var&amp;gt;UseDefault&amp;lt;/var&amp;gt; property of a&lt;br /&gt;
&amp;lt;var&amp;gt;[[NamedArraylist class|NamedArraylist]]&amp;lt;/var&amp;gt; by just using the enumeration value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%description is collection NamedArraylist of string len 64&lt;br /&gt;
  ...&lt;br /&gt;
%description:useDefault = true&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Common enumeration methods==&lt;br /&gt;
The methods listed below are available to all system enumerations. The individual method descriptions follow.&lt;br /&gt;
&amp;lt;ul class=&amp;quot;nobul&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#Copy function|Copy]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#DeepCopy function|DeepCopy]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#FromString function|FromString]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;var&amp;gt;[[#ToString property|ToString]]&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[#Using Boolean enumerations|versatile]] &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration has additional methods available.&lt;br /&gt;
&lt;br /&gt;
===Copy function===&lt;br /&gt;
This function returns an exact copy of the method object.&lt;br /&gt;
It is identical to the &amp;lt;var&amp;gt;[[#DeepCopy function|DeepCopy]]&amp;lt;/var&amp;gt; method.&lt;br /&gt;
Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no&lt;br /&gt;
different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]].&lt;br /&gt;
As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an&lt;br /&gt;
enumeration variable, and the presence of these methods simply&lt;br /&gt;
makes the copyability of enumeration variables explicit.&lt;br /&gt;
&lt;br /&gt;
====Copy syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%cop&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:Copy&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%cop&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable to contain the copy of &#039;&#039;enum&#039;&#039;. &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;%cop&amp;lt;/var&amp;gt; does not have to be [[XmlDoc API#XmlDoc states|empty]].&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The method object (&amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;) may be &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt;.&lt;br /&gt;
The output of a copy of a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object is a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
===DeepCopy function===&lt;br /&gt;
This function returns an exact copy of the method object.&lt;br /&gt;
It is identical to the &amp;lt;var&amp;gt;[[#Copy function|Copy]]&amp;lt;/var&amp;gt; method.&lt;br /&gt;
Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no&lt;br /&gt;
different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]].&lt;br /&gt;
As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an&lt;br /&gt;
enumeration variable, and the presence of these methods simply&lt;br /&gt;
makes the copyability of enumeration variables explicit.&lt;br /&gt;
&lt;br /&gt;
====DeepCopy syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%dcop&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:DeepCopy&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%dcop&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable to contain the deep copy of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;. &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;%dcop&amp;lt;/var&amp;gt; does not have to be [[XmlDoc API#XmlDoc states|empty]].&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The method object (&amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;) may be &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt;.&lt;br /&gt;
The output of a deep copy of a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object is a &amp;lt;var&amp;gt;Null&amp;lt;/var&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
===FromString function===&lt;br /&gt;
&amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; is a [[Notation conventions for methods#Shared methods|shared]] function that converts a string argument into a value of the specified enumeration type.&lt;br /&gt;
This is the opposite of the enumeration &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method, which converts an enumeration value to its &amp;lt;var&amp;gt;String&amp;lt;/var&amp;gt; representation.&lt;br /&gt;
&amp;lt;!-- &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; is available as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; Version 7.8. --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====FromString syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%enum&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;= [%(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enumType&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;):]&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;FromString(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;string&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or expression.  &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;&amp;lt;var class=&amp;quot;nobr&amp;quot;&amp;gt;%(&amp;lt;i&amp;gt;enumType&amp;lt;/i&amp;gt;)&amp;lt;/var&amp;gt; &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This explicit specification of the enumeration type in parentheses denotes a [[Object variables#Virtual Constructor methods|virtual constructor]]. See [[#Usage notes|&amp;quot;Usage notes&amp;quot;]], below, for more information about invoking this function. &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;string&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;A [[Longstrings|longstring]] variable that is assigned the current string value of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Usage Notes====&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;As an example, consider the following user-defined enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration Animal&lt;br /&gt;
    public&lt;br /&gt;
      value cat&lt;br /&gt;
      value dog&lt;br /&gt;
      value gecko&lt;br /&gt;
      value parrot&lt;br /&gt;
    end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can populate an &amp;lt;code&amp;gt;Animal&amp;lt;/code&amp;gt; enumeration variable with one of the &amp;lt;code&amp;gt;Animal&amp;lt;/code&amp;gt; enumeration values by making a call to &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt;:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet is enumeration animal&lt;br /&gt;
%pet = fromString(&#039;gecko&#039;)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The result of a &amp;lt;var&amp;gt;Print&amp;lt;/var&amp;gt; of &amp;lt;code&amp;gt;%pet&amp;lt;/code&amp;gt; above is &amp;lt;code&amp;gt;gecko&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; In the method call, &amp;lt;code&amp;gt;fromString&amp;lt;/code&amp;gt; might but does &#039;&#039;&#039;not&#039;&#039;&#039; have to be preceded by &amp;lt;code&amp;gt;%(Animal):&amp;lt;/code&amp;gt; to identify the type of enumeration, because the type is determined from the result variable. You could also get the same result from invoking with an already defined enumeration variable, as in:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet = %pet:fromString(&#039;gecko&#039;)&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;li&amp;gt;Only strings that match a value of the particular enumeration type&lt;br /&gt;
can be converted. If a string cannot be converted to an enumeration&lt;br /&gt;
value, &amp;lt;var&amp;gt;FromString&amp;lt;/var&amp;gt; throws an &amp;lt;var&amp;gt;[[InvalidValue class|Invalidvalue]]&amp;lt;/var&amp;gt; exception:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%pet = fromString(&#039;alien&#039;)&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;nowiki&amp;gt;***&amp;lt;/nowiki&amp;gt;  1  CANCELLING REQUEST: MSIR.0750: Class Animal, function&lt;br /&gt;
FromString: InvalidValue exception: ALIEN is not a valid enumeration&lt;br /&gt;
value in line 84, procedure ENUM, file MYPROC&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===ToString property===&lt;br /&gt;
This non-settable property examines an enumeration&lt;br /&gt;
and returns a printable or testable string representation of its value.&lt;br /&gt;
&lt;br /&gt;
====ToString syntax====&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;%ls&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;=&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;:ToString&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Syntax terms====&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;%ls&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;A [[Longstrings|longstring]] variable that is assigned the current string value of &amp;lt;var class=&amp;quot;term&amp;quot;&amp;gt;enum&amp;lt;/var&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;enum&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;An enumeration variable or an expression that results in an enumeration.&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;printenum&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
====Calling ToString implicitly====&lt;br /&gt;
&amp;lt;!-- As of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.3 --&amp;gt;To return a string representation of the value of a &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; system or user-defined enumeration, you can do either of the following:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Explicitly specify the &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Print (or audit) the value of an enumeration, and &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is implied,&lt;br /&gt;
as shown in the following example:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;begin&lt;br /&gt;
enumeration color&lt;br /&gt;
   public&lt;br /&gt;
      value red&lt;br /&gt;
      value white&lt;br /&gt;
      value blue&lt;br /&gt;
      value green&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
 &lt;br /&gt;
%x  is boolean initial(true)&lt;br /&gt;
%z  is enumeration color initial(blue)&lt;br /&gt;
%daem is object daemon&lt;br /&gt;
 &lt;br /&gt;
%daem = new&lt;br /&gt;
 &lt;br /&gt;
print %x with &#039; &#039; %z&lt;br /&gt;
[[PrintText statement|printText]] {~} = {%x}, {~} = {%z}&lt;br /&gt;
print %daem:haveDaemon&lt;br /&gt;
printText {~} = {%daem:haveDaemon}&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The &amp;lt;var&amp;gt;Print&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;PrintText&amp;lt;/var&amp;gt; statements above produce these results:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;True blue&lt;br /&gt;
%x = True, %z = blue&lt;br /&gt;
True&lt;br /&gt;
%daem:haveDaemon = True&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
In addition, the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; feature extends beyond enumerations:&lt;br /&gt;
upon any attempt to print or audit any object value, &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; will try to apply a&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method to the object.&lt;br /&gt;
If the object is an enumeration (as shown above) or is an&lt;br /&gt;
instance of a system or user-defined class that has a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method,&lt;br /&gt;
a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; is implicitly&lt;br /&gt;
applied and the result is a successful print or audit of the object value.&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
For example, the user-defined class in the following request includes a&lt;br /&gt;
&amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method.&lt;br /&gt;
The request&#039;s &amp;lt;code&amp;gt;printText&amp;lt;/code&amp;gt; statement prints &amp;lt;code&amp;gt;%x = a=11, b=22&amp;lt;/code&amp;gt;. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;begin&lt;br /&gt;
class mumble&lt;br /&gt;
  public&lt;br /&gt;
    variable   a is float&lt;br /&gt;
    variable   b is float&lt;br /&gt;
    constructor new(%a is float nameRequired, %b is float)&lt;br /&gt;
    function tostring is longstring&lt;br /&gt;
  end public&lt;br /&gt;
  constructor new(%a  is float nameRequired, %b is float)&lt;br /&gt;
    %this:a = %a&lt;br /&gt;
    %this:b = %b&lt;br /&gt;
  end constructor&lt;br /&gt;
  function tostring is longstring&lt;br /&gt;
    return &#039;a=&#039; with %a with &#039;, b=&#039; with %b&lt;br /&gt;
  end function&lt;br /&gt;
end class&lt;br /&gt;
 &lt;br /&gt;
   %x   is object mumble&lt;br /&gt;
   %x = new(a=11, b=22)&lt;br /&gt;
   printText {~} = {%x}&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
If the object you try to print or audit directly is not an enumeration or is&lt;br /&gt;
an instance of a class that does not have a &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method (system or&lt;br /&gt;
user-written), you receive a compilation error.&lt;br /&gt;
For example, if &amp;lt;code&amp;gt;%sl&amp;lt;/code&amp;gt; is a &amp;lt;var&amp;gt;Stringlist&amp;lt;/var&amp;gt; object, no user &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method exists,&lt;br /&gt;
and your request contains a &amp;lt;code&amp;gt;Print %sl&amp;lt;/code&amp;gt; statement, you get a message&lt;br /&gt;
like the following: &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;&amp;amp;#42;**  1  MSIR.0733: Member TOSTRING not found in class STRINGLIST&lt;br /&gt;
  print %sl&lt;br /&gt;
  (FILE = JALWORK, PROCEDURE = FOO, LINE = 28)&lt;br /&gt;
&amp;amp;#42;**  M204.1042: COMPILATION ERRORS&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
Finally, if the object you try to print directly is a &amp;lt;var&amp;gt;Unicode&amp;lt;/var&amp;gt; variable,&lt;br /&gt;
&amp;lt;!-- under &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; 7.6 and higher --&amp;gt;&lt;br /&gt;
the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method returns an EBCDIC character-encoded value for&lt;br /&gt;
Unicode characters that do not translate to EBCDIC.&lt;br /&gt;
This is described further in [[Unicode#Implicit Unicode conversions|&amp;quot;Implicit Unicode conversions&amp;quot;]]. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Boolean enumeration==&lt;br /&gt;
The [[Boolean enumeration]] is probably the most commonly used, and so the most important enumeration class. Because of its importance, it is treated specially by &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt;, and is a topic unto itself.&lt;br /&gt;
&lt;br /&gt;
==User enumerations==&lt;br /&gt;
While there are a wide variety of system enumerations that can be useful in&lt;br /&gt;
many contexts (especially the &amp;lt;var&amp;gt;Boolean&amp;lt;/var&amp;gt; enumeration), it is&lt;br /&gt;
also possible to define user enumerations in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt;.&lt;br /&gt;
This is done via the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; statement/block, which is very similar to the&lt;br /&gt;
&amp;lt;var&amp;gt;Class&amp;lt;/var&amp;gt; statement/block (as in [[Classes and Objects|&amp;quot;Classes and objects&amp;quot;]]).&lt;br /&gt;
&lt;br /&gt;
===The Enumeration block===&lt;br /&gt;
The &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; block can contain &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt;, and &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; blocks, just like any other class.&lt;br /&gt;
However, because enumeration classes don&#039;t really describe objects, there&lt;br /&gt;
can be no instance variables.&lt;br /&gt;
That is, the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; blocks cannot contain &amp;lt;var&amp;gt;Variable&amp;lt;/var&amp;gt; declarations.&lt;br /&gt;
 &lt;br /&gt;
Instead, the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block must contain one or more &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declarations&lt;br /&gt;
whose syntax is:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Value&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;attribute&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Each value declared by a &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declaration becomes one of the values of the enumeration. &lt;br /&gt;
&lt;br /&gt;
One or more &#039;&#039;&#039;attributes&#039;&#039;&#039; (a constant datum of type &amp;lt;var&amp;gt;String&amp;lt;/var&amp;gt;, &amp;lt;var&amp;gt;Float&amp;lt;/var&amp;gt;, or &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt;) can be attached to an enumeration value. &amp;lt;!-- (as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.8) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
No values or attributes are allowed in the &amp;lt;var&amp;gt;Private&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt; blocks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039; The value in a &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause is unusual in that the case (lower or upper)&lt;br /&gt;
of the characters in its value are saved and used in the implicit &amp;lt;var&amp;gt;ToString&amp;lt;/var&amp;gt; method. The same is true for the values in an &amp;lt;var&amp;gt;Attribute&amp;lt;/var&amp;gt; clause. &amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The following is an example of a simple enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shape&lt;br /&gt;
   public&lt;br /&gt;
      attribute code is string &lt;br /&gt;
&lt;br /&gt;
      value triangle      (code=&#039;31&#039;)&lt;br /&gt;
      value square        (code=&#039;44&#039;)&lt;br /&gt;
      value rhombus       (code=&#039;42&#039;)&lt;br /&gt;
      value rectangle     (code=&#039;41&#039;)&lt;br /&gt;
      value quadrilateral (code=&#039;40&#039;)&lt;br /&gt;
      value pentagon      (code=&#039;50&#039;)&lt;br /&gt;
      value circle        (code=&#039;01&#039;)&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All attributes must be declared before any value is declared. In a given &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;A specification for each attribute must be explicitly present.  &lt;br /&gt;
&amp;lt;li&amp;gt;An attribute may be specified by name or by position; and like a method [[Methods#Named_parameters|named parameter]], an attribute specified with its name may not precede an attribute specified only by position.&lt;br /&gt;
&amp;lt;li&amp;gt;An attribute name may not repeat.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Note:&#039;&#039;&#039;&lt;br /&gt;
Just as for &amp;lt;var&amp;gt;Class&amp;lt;/var&amp;gt; blocks, &amp;lt;!-- as of &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 7.3 --&amp;gt;&lt;br /&gt;
an &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; block you declare inside a method or complex subroutine&lt;br /&gt;
must be preceded by the keyword &amp;lt;var&amp;gt;Local&amp;lt;/var&amp;gt;.&lt;br /&gt;
For more information about locally-scoped classes and enumerations,&lt;br /&gt;
see [[Local and Common entities#Local classes, enumerations, and structures|&amp;quot;Local classes, enumerations, and structures&amp;quot;]].&lt;br /&gt;
&amp;lt;/P&amp;gt;&lt;br /&gt;
===Using user enumerations=== &lt;br /&gt;
You can use user-defined enumerations just like system enumerations.&lt;br /&gt;
That is, variables are declared with the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; keyword and class name:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape is enumeration shape&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values may be assigned to an enumeration variable:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape = circle&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Such a variable may be printed (&amp;lt;code&amp;gt;Print %cookieShape&amp;lt;/code&amp;gt;), and it may be used to access an enumeration attribute:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;Print %cookieShape:code&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More commonly, enumerations may be used as method parameters:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class cookie&lt;br /&gt;
   ...&lt;br /&gt;
   subroutine cut(%shape is enumeration shape)&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And, typically, literal values are used as the arguments when invoking&lt;br /&gt;
such a method:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%biscuit   is object cookie&lt;br /&gt;
 ...&lt;br /&gt;
%biscuit:cut(pentagon)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Enumeration values are not strings, so they are case insensitive.&lt;br /&gt;
While the class of an enumeration value can almost always be determined&lt;br /&gt;
from context, the class name can always be explicitly specified for a&lt;br /&gt;
value:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cookieShape = %(shape):circle&lt;br /&gt;
 ...&lt;br /&gt;
%biscuit:cut(%(shape):pentagon)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Like system enumerations, user enumeration variables can be in a state where&lt;br /&gt;
they have no value, that is, they can be null.&lt;br /&gt;
In fact, that is the initial value of any enumeration variable.&lt;br /&gt;
&lt;br /&gt;
As with system enumerations, you can change the default initial value&lt;br /&gt;
with the &amp;lt;var&amp;gt;Initial&amp;lt;/var&amp;gt; clause on the variable declaration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;syntax&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;variable&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Is&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Enumeration&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;enumerationName&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;literal&amp;quot;&amp;gt;Initial&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;(&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;term&amp;quot;&amp;gt;value&amp;lt;/span&amp;gt;&amp;lt;span class=&amp;quot;squareb&amp;quot;&amp;gt;)]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can set the default initial value for local variables:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%cutout is enumeration shape initial(square)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And you can set it for variables in class blocks:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;class cookie&lt;br /&gt;
   public&lt;br /&gt;
      variable shape is enumeration shape initial(round)&lt;br /&gt;
      ...&lt;br /&gt;
   end public&lt;br /&gt;
   ...&lt;br /&gt;
end class&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Of course, instance-specific (non-&amp;lt;var&amp;gt;Shared&amp;lt;/var&amp;gt;) initial values are set&lt;br /&gt;
for each instance of the class when it is created.&lt;br /&gt;
&lt;br /&gt;
===Enumeration methods===&lt;br /&gt;
Enumeration classes can also contain methods that operate on&lt;br /&gt;
or are related to the enumeration values.&lt;br /&gt;
For example, the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration can have a method that returns the number&lt;br /&gt;
of sides in a shape:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shape&lt;br /&gt;
   public&lt;br /&gt;
      ...&lt;br /&gt;
      function sides is float&lt;br /&gt;
   end public&lt;br /&gt;
   function sides is float&lt;br /&gt;
      if %this eq circle then&lt;br /&gt;
         return 0&lt;br /&gt;
      end if&lt;br /&gt;
      if %this eq triangle then&lt;br /&gt;
         return 3&lt;br /&gt;
      end if&lt;br /&gt;
      ...&lt;br /&gt;
   end function&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
As this example illustrates, the implicit &amp;lt;code&amp;gt;%this&amp;lt;/code&amp;gt; variable for enumeration&lt;br /&gt;
methods contains not an object reference but an enumeration value.&lt;br /&gt;
 &lt;br /&gt;
Enumeration methods can be applied to enumeration values as well as enumeration variables.&lt;br /&gt;
This is one case, however, where the enumeration value &#039;&#039;&#039;must&#039;&#039;&#039;&lt;br /&gt;
be qualified with the class name, because it appears in a context where&lt;br /&gt;
the class cannot be determined otherwise:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;print %(shape):rhombus:sides&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
And, as with objects, an enumeration method could be applied to the output&lt;br /&gt;
of another method that returns an enumeration value.&lt;br /&gt;
For example, if the &amp;lt;code&amp;gt;PickCookie&amp;lt;/code&amp;gt; method of the &amp;lt;code&amp;gt;Jar&amp;lt;/code&amp;gt; class returns a&lt;br /&gt;
&amp;lt;code&amp;gt;Cookie&amp;lt;/code&amp;gt; object, and the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; method of the &amp;lt;code&amp;gt;Cookie&amp;lt;/code&amp;gt; class returns a&lt;br /&gt;
&amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration value, the following prints the number of sides of&lt;br /&gt;
a picked cookie:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%jar   is object jar&lt;br /&gt;
 ...&lt;br /&gt;
print %jar:pickCookie:shape:sides&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Inverse attribute methods===&lt;br /&gt;
Inverse attribute methods let you derive an enumeration &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; based on the value of one of&lt;br /&gt;
its &amp;lt;var&amp;gt;[[#The Enumeration block|Attributes]]&amp;lt;/var&amp;gt;. To do so, you declare an &amp;lt;code&amp;gt;inverse&amp;lt;/code&amp;gt; method at the end of an &amp;lt;var&amp;gt;Attribute&amp;lt;/var&amp;gt; declaration, then you invoke the method, as is shown with the &amp;lt;code&amp;gt;fromOz&amp;lt;/code&amp;gt; method in this example: &lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration coffee                                                      &lt;br /&gt;
    public&lt;br /&gt;
       attribute oz is float inverse fromOz   &lt;br /&gt;
&lt;br /&gt;
       value tall   (12) &lt;br /&gt;
       value grande (16) &lt;br /&gt;
       value venti  (20) &lt;br /&gt;
    end public   &lt;br /&gt;
end enumeration            &lt;br /&gt;
&lt;br /&gt;
%order is enumeration coffee &lt;br /&gt;
&lt;br /&gt;
%order = fromOz(16)   &lt;br /&gt;
Print %order&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The result is: &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;grande&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Usage notes====&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Inverse attribute calls throw an &amp;lt;var&amp;gt;[[InvalidValue class|InvalidValue]]&amp;lt;/var&amp;gt; exception if the given value cannot be inverted. &lt;br /&gt;
&amp;lt;li&amp;gt;Since the same attribute value may appear in more than one &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; specification,&lt;br /&gt;
inverse attribute calls are checked at compile time for such ambiguous&lt;br /&gt;
value parameters. If you try to invert an attribute value that has multiple possible inverses, &lt;br /&gt;
you receive &amp;lt;code&amp;gt;MSIR.1029: Attribute error: Duplicate values specified for &lt;br /&gt;
invertible attribute&amp;lt;/code&amp;gt; when you attempt to compile the offending enumeration.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automatic methods===&lt;br /&gt;
Several methods are automatically provided for &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;SOUL&amp;lt;/var&amp;gt; enumeration&lt;br /&gt;
classes.&lt;br /&gt;
Some of these are identical to common methods available in most system&lt;br /&gt;
enumerations.&lt;br /&gt;
These methods are:&lt;br /&gt;
&amp;lt;table class=&amp;quot;thJustBold&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Copy&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Performs a &amp;amp;ldquo;copy&amp;amp;rdquo; of the enumeration value. Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]]. As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; of an enumeration variable, and the presence of these methods simply makes the copyability of enumeration variables explicit.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;DeepCopy&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Performs a &amp;amp;ldquo;copy&amp;amp;rdquo; of the enumeration value. Since enumeration variables simply have values, a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;DeepCopy&amp;lt;/var&amp;gt; is no different from an assignment, so enumerations are always copyable and deep&lt;br /&gt;
copyable, as described in [[Copying objects|&amp;quot;Copying objects&amp;quot;]]. As such, there is no real reason to do a &amp;lt;var&amp;gt;Copy&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;Or&amp;lt;/var&amp;gt; DeepCopy of an enumeration variable, and the presence of these methods simply makes the copyability of enumeration variables explicit.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;FromOrdinal&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This shared method is the inverse of the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method and converts an ordinal number to an enumeration value. The class specified in the shared method invocation determines the class of the result enumeration value.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
This method was introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;[[Sirius Mods]]&amp;lt;/var&amp;gt; Version 8.1.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;NumberOfValues&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;This shared method returns the number of values in the enumeration class. The class specified in the shared method invocation determines the class whose value count is returned.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block.&lt;br /&gt;
&lt;br /&gt;
This method was introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;[[Sirius Mods]]&amp;lt;/var&amp;gt; Version 8.1.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;Ordinal&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Returns the ordinal position of the &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; clause associated with the value of the enumeration. For example, if an enumeration was declared as follows:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration shot&lt;br /&gt;
   public&lt;br /&gt;
      value rock&lt;br /&gt;
      value paper&lt;br /&gt;
      value scissors&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The ordinal for a value of &amp;lt;var&amp;gt;Rock&amp;lt;/var&amp;gt; is 1, for &amp;lt;var&amp;gt;Paper&amp;lt;/var&amp;gt; 2, and &amp;lt;var&amp;gt;Scissors&amp;lt;/var&amp;gt; 3.&lt;br /&gt;
By default, the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method behaves as if it is a private method. That is, it can only be accessed inside the class. This can be overridden by specifying &amp;lt;code&amp;gt;Allow Ordinal&amp;lt;/code&amp;gt; in the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block, as described below.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;ToString&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Returns a string representation of the enumeration value.&lt;br /&gt;
The value returned uses the same case for the characters as was used on the &amp;lt;var&amp;gt;Value&amp;lt;/var&amp;gt; declaration.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Using the Ordinal method====&lt;br /&gt;
The &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method, especially, bears further discussion.&lt;br /&gt;
It can be very useful in writing enumeration methods, especially in&lt;br /&gt;
conjunction with the &amp;lt;var&amp;gt;Jump&amp;lt;/var&amp;gt; statement.&lt;br /&gt;
For example, the &amp;lt;code&amp;gt;Sides&amp;lt;/code&amp;gt; method in the &amp;lt;code&amp;gt;Shape&amp;lt;/code&amp;gt; enumeration above could have been&lt;br /&gt;
written like:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;function sides is float&lt;br /&gt;
   jump to (three, four, four, four, four, five, none) %this:ordinal&lt;br /&gt;
   three: return 3&lt;br /&gt;
   four:  return 4&lt;br /&gt;
   five:  return 5&lt;br /&gt;
   none:  return 0&lt;br /&gt;
end function&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
While this might justifiably be disparaged as questionable programming technique,&lt;br /&gt;
it &#039;&#039;&#039;is&#039;&#039;&#039; very efficient and simple.&lt;br /&gt;
 &lt;br /&gt;
One disadvantage of such a technique is that the code is now highly&lt;br /&gt;
dependent on the order of the value declarations.&lt;br /&gt;
This means that it becomes difficult to rearrange the value declarations,&lt;br /&gt;
or to insert one into the list after there is code that uses the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt;&lt;br /&gt;
method on an enumeration class.&lt;br /&gt;
For this reason, the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method behaves like a private method, by&lt;br /&gt;
default.&lt;br /&gt;
That is, it is only available to methods inside the &amp;lt;var&amp;gt;Enumeration&amp;lt;/var&amp;gt; class&lt;br /&gt;
block.&lt;br /&gt;
 &lt;br /&gt;
One use of the &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method that you might want to make public occurs&lt;br /&gt;
when the enumeration values have a natural ordering.&lt;br /&gt;
Consider, for example, the following enumeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration volume&lt;br /&gt;
   public&lt;br /&gt;
      value low&lt;br /&gt;
      value medium&lt;br /&gt;
      value high&lt;br /&gt;
      value deafening&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
With such an enumeration, one might want to use an enumeration value&#039;s&lt;br /&gt;
ordinality in comparisons.&lt;br /&gt;
To allow this to be done, the &amp;lt;var&amp;gt;Allow Ordinal&amp;lt;/var&amp;gt; directive must be placed in&lt;br /&gt;
the &amp;lt;var&amp;gt;Public&amp;lt;/var&amp;gt; block of the enumeration definition:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration volume&lt;br /&gt;
   public&lt;br /&gt;
      allow ordinal&lt;br /&gt;
      value low&lt;br /&gt;
      value medium&lt;br /&gt;
      value high&lt;br /&gt;
      value deafening&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Then, code like the following can be used outside the class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%leftSpeakerVolume  is enumeration volume&lt;br /&gt;
%rightSpeakerVolume is enumeration volume&lt;br /&gt;
 ...&lt;br /&gt;
if %leftSpeakerVolume:ordinal gt -&lt;br /&gt;
   %rightSpeakerVolume:ordinal then&lt;br /&gt;
   ...&lt;br /&gt;
end if&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Of course, the same effect could be achieved by adding a different method&lt;br /&gt;
to the enumeration, called perhaps &amp;lt;code&amp;gt;Level&amp;lt;/code&amp;gt;, that returned a non-ordinal value&lt;br /&gt;
that could still be used for comparisons:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%leftSpeakerVolume  is enumeration volume&lt;br /&gt;
%rightSpeakerVolume is enumeration volume&lt;br /&gt;
 ...&lt;br /&gt;
if %leftSpeakerVolume:level gt -&lt;br /&gt;
   %rightSpeakerVolume:level then&lt;br /&gt;
   ...&lt;br /&gt;
end if&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The advantage of this approach is that a non-ordinal value is less likely&lt;br /&gt;
to be misused for computed jumps, and the levels leave space to add values&lt;br /&gt;
associated with new enumeration values.&lt;br /&gt;
Another approach that avoids exposing the ordinal values of an&lt;br /&gt;
enumeration is to provide a comparison method to compare two enumeration&lt;br /&gt;
values.&lt;br /&gt;
&lt;br /&gt;
====Using the FromOrdinal and NumberOfValues methods====&lt;br /&gt;
The &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; methods were introduced in &amp;lt;var class=&amp;quot;product&amp;quot;&amp;gt;Sirius Mods&amp;lt;/var&amp;gt; version 8.1.&lt;br /&gt;
&lt;br /&gt;
These two methods make it easy to enumerate all the values in an enumeration class without having to maintain code that has a list of all the values. Because these methods could be used to build an equivalent to the automatic &amp;lt;var&amp;gt;Ordinal&amp;lt;/var&amp;gt; method, they require &amp;lt;var&amp;gt;Allow Ordinal&amp;lt;/var&amp;gt; to be set in the enumeration class against which they are used (see example below).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method is a [[Shared_class_members|shared method]] and has a single input argument: the ordinal number of the value to which to set the target enumeration variable. For example, if one has a &amp;lt;var&amp;gt;Stooge&amp;lt;/var&amp;gt; enmeration:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;enumeration stooge&lt;br /&gt;
   public&lt;br /&gt;
      value moe&lt;br /&gt;
      value larry&lt;br /&gt;
      value curly&lt;br /&gt;
      value shemp&lt;br /&gt;
      allow ordinal&lt;br /&gt;
   end public&lt;br /&gt;
end enumeration&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
then the following sequence:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite is enumeration stooge&lt;br /&gt;
%favorite = %(stooge):fromOrdinal(3)&lt;br /&gt;
printText {~=%favorite}&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
would print:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite=curly&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
If an invalid ordinal number is specified as input to the &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; method, an &amp;lt;var&amp;gt;[[InvalidValue_class|InvalidValue]]&amp;lt;/var&amp;gt; exception is thrown. For example, the following:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%favorite = %(stooge):fromOrdinal(-5)&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
would result in the following request canceling error message:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;MSIR.0750: Class Stooge, function FromOrdinal: InvalidValue exception: -5 is not -&lt;br /&gt;
a valid ordinal number for class Stooge ...&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
You can catch such an exception to produce a list of all values in an enumeration class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;for %i from 1 to 99999999&lt;br /&gt;
   try printText {%(stooge):fromOrdinal(%i)}&lt;br /&gt;
   catch invalidValue; loop end&lt;br /&gt;
   end try&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This outputs:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;moe&lt;br /&gt;
larry&lt;br /&gt;
curly&lt;br /&gt;
shemp&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; automatic method for enumerations lets you do this a little more tidily:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;for %i from 1 to %(stooge):numberOfValues&lt;br /&gt;
   printText {%(stooge):fromOrdinal(%i)}&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
The &amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; method has no parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;var&amp;gt;NumberOfValues&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;FromOrdinal&amp;lt;/var&amp;gt; can be used to build an [[Arraylist_class|Arraylist]] that contains one item for each value in the enumeration class:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%stoogeValues    is arraylist of enumeration stooge&lt;br /&gt;
 ...&lt;br /&gt;
%stoogeValues = new&lt;br /&gt;
for %i from 1 to %(stooge):numberOfValues&lt;br /&gt;
   %stoogeValues:add(%(stooge):fromOrdinal(%i))&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
One advantage of having such an &amp;lt;var&amp;gt;Arraylist&amp;lt;/var&amp;gt; is that it can easily be sorted or searched. For example, the following displays the stooge values sorted in ascending character order:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;%stoogevalues:[[SortNew_(GenericNamedArraylist_function)|sortNew]](ascending(toString)):print&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This displays:&lt;br /&gt;
&amp;lt;p class=&amp;quot;code&amp;quot;&amp;gt;1: curly&lt;br /&gt;
2: larry&lt;br /&gt;
3: moe&lt;br /&gt;
4: shemp&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[[Object oriented programming in SOUL]]&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:SOUL object-oriented programming topics]]&lt;/div&gt;</summary>
		<author><name>NMichell</name></author>
	</entry>
</feed>