home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / m2t-2.zip / SUBRANGE.MOD < prev    next >
Text File  |  1989-01-18  |  2KB  |  58 lines

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