Enums (Oxygene)
From RemObjects Software
This is a Oxygene Language Feature topic
Feel free to add your notes to this topic below.
Enums are simple, integer based types that can be used as an enumeration, where an enum has 1 value out of a list, or a bitflag, where it has several bits defining its value.
An enum is a special type and is restricted to only have possible values defined as constants on the enum.
The syntax used to define and use enum is:
type MyEnum = enum (a,b,c, d = 255); var r: MyEnum; begin r := MyEnum.b; ... if r = MyEnum.c then
The members of an enum are automatically assigned a value if none is given, starting at 0, increasing 1 from the previous member. When using the flags keyword instead of enum a special kind of enum can be defined. Here the members increase by finding the next in the Power(2, n) sequence.
type MyFlags = flags(a, b, c); begin r := MyFlags.a; r := r + MyFlags.c; if MyFlags.b in r then ...
Typed Enums
An extended syntax is provided to assign enums a specific integer type for internal storage by suffixing of type" to the enum deceleration:
type x = enum (a,b,c) of byte; y = (a,b,c) of byte;
Supported types are: Byte, SByte, Int16, Unt32, Unt64, UInt16, UInt32 and UInt64
See Also
Product: RemObjects Oxygene (formerly known as Chrome)
Current version: 3.0
Previous Versions: 'Joyride' (2.0), 'Floorshow' (1.5), 'Adrenochrome' (1.0)
Glossary — Keywords — Language Features — Platform Features — Samples — Articles — How To — Issues
Categories: Text | Oxygene | Feature
