Difference between revisions of "HPL3/Scripting/Scripting Guide/Enums"
< HPL3
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
{{Hpl3ScriptingGuideMenuBasic}} | {{Hpl3ScriptingGuideMenuBasic}} | ||
{{shortPageTitle}} | {{shortPageTitle}} | ||
− | + | {| style="border:0px;" cellspacing="0" | |
+ | |- valign="top" | ||
+ | | style="padding-right:0.2em" | | ||
Enum is a user defined datatype in HPL3. It is used to assign names to the integral constants which makes a script easy to read and maintain. The keyword <code>enum</code> is used to declare an enumeration. | Enum is a user defined datatype in HPL3. It is used to assign names to the integral constants which makes a script easy to read and maintain. The keyword <code>enum</code> is used to declare an enumeration. | ||
Line 30: | Line 32: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | {| style="border:0px;" cellspacing="0" | |
+ | |- valign="top" | ||
+ | | style="padding-right:0.2em" | | ||
==Using Enums== | ==Using Enums== | ||
The following example demonstrates use of <code>enum</code> variable:<syntaxhighlight lang="c++"> | The following example demonstrates use of <code>enum</code> variable:<syntaxhighlight lang="c++"> |
Revision as of 23:52, 14 August 2020
Enum is a user defined datatype in HPL3. It is used to assign names to the integral constants which makes a script easy to read and maintain. The keyword Declaring Enum VariableThe general syntax for declaring an enumeration is enum enum_name
{
enumeration list
}
Where:
Each of the symbols in the enumeration list stands for an integer value, one greater than the symbol that precedes it. By default, the value of the first enumeration symbol is 0. For example: enum WeekDay
{
Day_Sun, // The value here is 0
Day_Mon, // The value here is 1
Day_Tue, // etc
Day_Wed,
Day_Thu,
Day_Fri,
Day_Sat
}
|