Declares an enumerated data type.
[scope] type type-name is enum enum-values
Variable | Description |
---|---|
scope | Optional: Either public (the default) or private. Private declarations are available only in the file in which they occur. Public declarations can be accessed from other files by means of a use statement. |
type-name | An identifier that names the type being declared. |
enum-values | One or more of values on separate lines. By default, the first value in the list of enumerated values is assigned sequence value 1, and each subsequent value is incremented by 1. If you explicitly assign an INTEGER sequence value, as shown in the example below, the values that follow it are incremented by 1. |
An enumerated data type is a data type that groups together a set of values and orders them sequentially from 1 to n. You declare an enumerated type when you want a variable to hold only a limited number of distinct values. For example, you can define an enumerated type named colors whose legal values are "red" and "green" and "yellow".
[-] type COLOR is enum [ ] red [ ] green [ ] // red = 1, green = 2 [-] type YESNO is enum [ ] NO = 0 [ ] YES [ ] // NO = 0, YES = 1