t62_enum.pas 1.2 KB

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