Subrange.mod 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. MODULE Subrange;
  2. TYPE Days = (mon,tue,wed,thu,fri,sat,sun);
  3. Work = [mon..fri];
  4. Rest = [sat..sun];
  5. VAR Day : Days; (* This is any day of the week *)
  6. Workday : Work; (* These are the working days *)
  7. Weekend : Rest; (* The two weekend days only *)
  8. Index : [1..12];
  9. Alphabet : ['a'..'z'];
  10. Start : ['a'..'e'];
  11. BEGIN (* Main program *)
  12. (* The following statements are commented out because they
  13. contain various errors that will halt compilation.
  14. Workday := sat; sat is not part of Workday's subrange.
  15. Rest := fri; fri is not part of Rest's subrange.
  16. Index := 13; Index is only allowed to go up to 12,
  17. Index := -1; and down to 1.
  18. Alphabet := 'A'; Alphabet, as defined, includes only the
  19. lowercase alphabet.
  20. Start := 'h'; h is not in the first five letters.
  21. End of the commented out section of program.
  22. *)
  23. Workday := tue;
  24. Weekend := sat;
  25. Day := Workday;
  26. Day := Weekend;
  27. Index := 3 + 2 * 2;
  28. Start := 'd';
  29. Alphabet := Start;
  30. (* Since Alphabet is 'd' *)
  31. INC(Alphabet); (* and now 'e' *)
  32. Start := Alphabet; (* Start will be 'e' *)
  33. DEC(Start);
  34. DEC(Start); (* Start will be 'c' *)
  35. Day := wed;
  36. INC(Day); (* Day will now be 'thu' *)
  37. INC(Day); (* Day will now be 'fri' *)
  38. Index := ORD(Day); (* Index will be 4 (fri = 4) *)
  39. END Subrange.