| 123456789101112131415161718192021222324252627282930 |
- program t62_enum;
- { t62 -- enumeration types: CALC.PAS:120 is
- Attributes = (Constant, Formula, Txt, OverWritten, Locked, Calculated);
- Each enumerator becomes a constant holding its ordinal position, so the six
- names are 0..5 and compare as ordinals. The TYPE is one byte (TP3 uses one
- below 256 values) and carries its bounds 0..n-1, which the next line needs:
- `SetOfAttri = Set of Attributes' sizes its set base from 0..5 -> ONE byte,
- where `set of Char' is 32.
- Enumerators are TScalar constants rather than a class of their own: they
- behave as ordinals, and only the TYPE carries the enum identity. A set
- literal over enumerators (`[Constant, Formula]') defaults to `set of Char',
- which is a superset and still answers membership correctly; a `set of
- Attributes' VARIABLE, when set variables land, will be the 1-byte one. }
- type
- Attributes = (Constant, Formula, Txt, OverWritten, Locked, Calculated);
- SetOfAttri = Set of Attributes;
- var
- a : Attributes;
- begin
- a := Locked;
- writeln (a = Locked); { same enumerator }
- writeln (a = Txt); { different one }
- writeln (Constant in [Constant, Formula]);
- writeln (Txt in [Constant, Formula])
- end.
|