411 REFERENCE · Wikibooks
Futurebasic/Language/Reference/begin enum
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Begin Enum
Statement
✔ Appearance ✔ Standard ✔ Console
Syntax
begin enum [start [,inc]]
_constName1 [= staticExpression1]
_constName2 [= staticExpression2]
_constName3 [= staticExpression3]
_constName4 [= staticExpression4]
end enum
Description
This statement begins a block of "enumerated constant" definition lines. The block must be terminated with the end enum statement. All of the constants defined in this block are global, regardless of where in the program the block appears.
The begin enum...end enum block is "non-executable," which implies that it won't be repeated or skipped if it appears within any kind of "conditional execution" block, such as for...next, long if...end if, do...until, etc. (but it can be conditionally included or excluded if it appears inside a compile long if block).
Each _constName represents a symbolic constant name that has not previously been defined, and each staticExpression represents an integer expression which consists only of:
<li type="disc">integer literal constants;
<li type="disc">previously-defined symbolic constant names;
<li type="disc">operators (like +, -, *, /, >, =);
<li type="disc">parentheses
(In particular, it can't contain variables, nor function references.)
The begin enum block assigns values to each of the _constName symbolic constants as follows:
<li type="disc">If the _constName is followed by = staticExpression, then _constName is assigned the value of staticExpression;
<li type="disc">If the _constName is not followed by = staticExpression, then _constName is assigned the value of the _constName in the line above it, plus the value of inc;
<li type="disc">If the very first _constName is not followed by = staticExpression, then it's assigned the value of start.
The start and inc parameters, if included, must each be a static integer expression. The default value of start is 0, and the default value of inc is 1.
Example
In the following, the dwarves are assigned values of 1 through 7; _snowWhite is assigned the value 100, and _thePrince is assigned the value 101.
begin enum 1
_docDwarf
_sneezy
_grumpy
_sleepy
_dopey
_happy
_bashful
_snowWhite = 100
_thePrince
end enum
Notes
No special notes.
See Also
Language Reference