Syntax
Declares a run of numbered constants, one per line. ENUMERATIONBINARY doubles the value at each line, for flags.
ENUMERATION [<group>] [<start> [STEP <step>]]
#<NAME> [= <value>]
…
ENDENUMERATION
ENUMERATIONBINARY [<group>] [<start>]
#<NAME> [= <value>]
…
ENDENUMERATIONAlso written : ENUMERATIONBINARY, ENDENUMERATION
Parts
| <group> | Optional name. Opening an enumeration with the same name again continues where it stopped. |
|---|---|
| <start> | The first value. Default 0, or 1 for ENUMERATIONBINARY. |
| <step> | What is added at each line. Default 1. ENUMERATIONBINARY refuses STEP. |
| <NAME> | The name of one constant, written with #. One per line. |
| <value> | Optional value for this constant; the next lines continue from it. |
Good to know
- Values are whole numbers:
0.5is rounded to 1.<start>,<step>and<value>are numbers or expressions of other constants; a command call is refused. - The block closes with
ENDENUMERATIONonly.END ENUMERATIONis not accepted. - Each line holds one
#NAMEand nothing else:#A, #Band a comment after the name are refused (BASIC enumeration accepts only #Constant entries). - Nested enumerations, reopening a named one in the other mode, and
ENUMERATIONBINARY 1 STEP 2are refused. ENUMERATION STEP 2is not refused:STEPis read as the enumeration's name and 2 as its start, so the values are 2, 3, 4. Always give a start:ENUMERATION 0 STEP 2.- Like
#CONSTANT, an enumeration constant cannot be read from a FUNCTION in a program with aDO … LOOP.
Example
ENUMERATION #RED #GREEN #BLUEENDENUMERATIONENUMERATION 10 STEP 5 #A #B #C = 100 #DENDENUMERATIONENUMERATIONBINARY #FLAG_A #FLAG_B #FLAG_CENDENUMERATIONConsole(Str(#RED) + Str(#GREEN) + Str(#BLUE)) ' 012Console(Str(#A) + " " + Str(#B) + " " + Str(#C) + " " + Str(#D)) ' 10 15 100 105Console(Str(#FLAG_A) + " " + Str(#FLAG_B) + " " + Str(#FLAG_C)) ' 1 2 4In the manual : Constants and operators