Futurebasic/Language/Reference/begin enum

Begin Enum

edit

Statement

edit

✔ Appearance ✔ Standard ✔ Console

Syntax

edit
begin enum [start [,inc]]
  _constName1 [= staticExpression1]
  _constName2 [= staticExpression2]
  _constName3 [= staticExpression3]
  _constName4 [= staticExpression4]
end enum

Description

edit

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:

  • integer literal constants;
  • previously-defined symbolic constant names;
  • operators (like +, -, *, /, >, =);
  • 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:

  • If the _constName is followed by = staticExpression, then _constName is assigned the value of staticExpression;
  • 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;
  • 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

edit

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

edit

No special notes.

See Also

edit

Language Reference