An Enumeration is simply a fixed range of named values integer-based types, which may have explicit or automatically
assigned values. Enumerations can be cast to and from Integer.
When you want to use an enumeration variable, you must define the range of possible values in an enumeration type
first Since enumeration variables and values can also be treated as numbers (ordinals).
We can use them in expressions and we can also use them in loops.
In the following example, the value of day can be treated as a number or an enumeration value.
To treat as a number, you must use the Ord function.
Using enumerations in SmartMS example 1
Explicitly scoped enumerations are supported using the enum keyword:
type MyEnumeration = enum(First, Second,Third,Tenth=10,Eleventh);
With this syntax, enumeration elements must be referred with the enumeration type as scope, as in
MyEnumeration.First. If values aren’t specified explicitly, they start from 0 and increase by 1 from the previous member.
Another variant of enumerations is when using the flags keyword, in that case, values cannot be
explicit, and they start from 1 and are multiplied by 2 from the previous member (1, 2, 4, 8 etc.)
type MyFlags = flags(Alpha,Beta,Gamma);
With this syntax too the elements can only be accessed through explicit scoping as in MyFlags.Beta.
Finally, the classic Object Pascal enumeration syntax is supported:
type TMyEnumeration = (firstEnum,secondEnum,thirdEnum);
type TMyExplicitEnum = (eeOne=1,eeTwo=3,eeFive=5);
With this classic syntax, an enumeration element can be referred directly (eeOne) or prefixed with
the enumeration type (TMyExplicitEnum.eeOne).
Set of enumerations with Records in SmartMS.
Using enumerations in SmartMS example 3 TODO
Using enumerations in SmartMS example 4 TODO
|