home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_02 / 1n02041a < prev    next >
Text File  |  1990-07-09  |  1KB  |  63 lines

  1.  
  2. ----------
  3.  
  4. type
  5.     month =
  6.         (
  7.         JAN, FEB, MAR, APR, MAY, JUN,
  8.         JUL, AUG, SEP, OCT, NOV, DEC
  9.         );
  10.     month_image_type = array [JAN..DEC] of string[3];
  11. const
  12.     month_image : month_image_type =
  13.         (
  14.         'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
  15.         'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
  16.         );
  17.  
  18. {*
  19.  * Read a month from text file f into m using image table t.  If
  20.  * the read is unsuccessful, set InOutRes (from the System unit)
  21.  * so that the next call on IOResult will indicate an error.
  22.  *}
  23. procedure read_month
  24.         (var f : text; var m : month; var t : month_image_type);
  25.     var
  26.         s : string;
  27.         mm : month;
  28.     begin
  29.     read(f, s);
  30.     readln(f);
  31.     for mm := JAN to DEC do
  32.         if s = t[mm] then
  33.             begin
  34.             m := mm;
  35.             exit;
  36.             end;
  37.     InOutRes := 106;    { See Turbo Pascal 5.5 Ref page 445 }
  38.     end;
  39.  
  40. { include function monthly_week_days from Listing 2 }
  41.  
  42. .
  43. .
  44. var
  45.     cal : annual_calendar;
  46.     m : month;
  47. begin
  48. while not eof do
  49.     begin
  50.     read_month(input, m, month_image);
  51.     if IOResult <> 0 then
  52.         writeln('invalid month')
  53.     else
  54.         begin
  55.         write('week days in ', month_image[m]);
  56.         writeln(' = ', monthly_week_days(cal[m]):0);
  57.         end;
  58.     end;
  59. end.
  60.  
  61. Listing 5 - Reading an Enumeration in Turbo Pascal
  62.  
  63.