ENUM/END ENUM statements

Purpose | Creates a group of logically related numeric equates.
Syntax | ENUM Name [SINGULAR] [BITS] [AS COM] EquateName [= value] EquateName [= value] ... END ENUM
Remarks | PowerBASIC allows you to refer to integral numeric constants by name. These names are called equates, and are visible throughout your program. If you need a set of equates which are logically related, you can define them as a group in an enumeration. This provides meaningful names for the enumeration, its members, and therefore the name by which it is referenced. When an equate is created in an enumeration, its name is composed of a leading percent sign (%), the enumeration name, a period (.), and then the member name. For example: ENUM abc count = 7 END ENUM In the above example, the equate is referenced as %abc.count, and returns the value seven (7). Each member of an enumeration may be assigned a specific integral value (in the range of a 64-bit quad integer) by using the optional [=value] syntax. In this case, only a constant value (or a simple constant/literal expression) may be assigned to it. If an expression is used, all of the terms in the expression must be constants; numeric equates; bitwise operators like AND, OR, NOT; arithmetic operators +, -, *, /, \; the relational operators >, <, >=, <=, <>, =; and the CVQ function. If the [=value] option is omitted, each member of the enumeration is assigned an integral value in sequence beginning with the value 0. If one or more equates are assigned an explicit value, equates which follow are assigned the next value in the sequence. For example: ENUM abc direction count = 8 scope END ENUM In the above example, %abc.direction = 0, %abc.count = 8, and %abc.scope = 9.
BITS | If the BITS option is included, the members are auto-assigned values suitable for use as a bit mask, increasing as integral powers of two. The first member is auto-assigned the value 0, the next is 1, then 2, 4, 8, 16, etc. If one or more are assigned an explicit value, equates which follow are assigned the next value in the sequence. For example: ENUM abc BITS direction = 1 count = 8 scope END ENUM In the above example, %abc.direction = 1, %abc.count = 8, and %abc.scope = 16.
SINGULAR | If the SINGULAR option is included, the member name is the complete name, without the ENUM name or the period. The equate is referenced by just the member name with a percent (%) prepended. For example: ENUM abc SINGULAR count = 7 END ENUM In the above example, the equate would normally be referenced by the compound name %abc.count. However, since it includes the SINGULAR option, it is referenced by the simplified name %count.
AS COM | If you are using a version of PowerBASIC which creates COM servers, you can easily include these equates in your type library; just append the words AS COM to the ENUM definition.