Often you want to define a whole lot of constants and you just want them all to have a different value so you can tell them apart easily. For instance, if you wanted to define some constants to represent some famous cities and you only needed to know how to distinguish one from another then you could use an enumeration like this:
ENUM LONDON, MOSCOW, NEW_YORK, PARIS, ROME, TOKYO
ENUM keyword begins the definitions (like the
CONST keyword does for an ordinary constant definition).
The actual values of the constants start at zero and stretch up to five.
In fact, this is exactly the same as writing:
CONST LONDON=0, MOSCOW=1, NEW_YORK=2, PARIS=3, ROME=4, TOKYO=5
The enumeration does not have to start at zero, though. You can change the starting value at any point by specifying a value for an enumerated constant. For example, the following constant definitions are equivalent:
ENUM APPLE, ORANGE, CAT=55, DOG, GOLDFISH, FRED=-2, BARNEY, WILMA, BETTY CONST APPLE=0, ORANGE=1, CAT=55, DOG=56, GOLDFISH=57, FRED=-2, BARNEY=-1, WILMA=0, BETTY=1
Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.