home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 349_01 / sss.arc / EX_0401.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-11  |  1KB  |  78 lines

  1. Program EX_0401;
  2. {Listing 6P - see documentation in TUTOR.SSS}
  3.  
  4. uses SSS;
  5. { For Pascal other than Turbo/Quick erase above line }
  6.  
  7. const
  8.   ARRIVL = 1;
  9.   TRYBUY = 2;
  10.   REPLNS = 3;
  11.  
  12.   CUSTMR = 0;
  13.   GOODS  = 1;
  14.  
  15. { For MS Pascal $include:'SSSP1.H' }
  16.  
  17. var
  18.   c, ecode : integer;
  19.  
  20. { For MS Pascal $include:'SSSP2.H' }
  21.  
  22. procedure prime;
  23. begin
  24.   INIQUE(0,0,2);
  25.   INISTA(1,'Out of stock',0,0,0,0);
  26.   INISTA(2,'Ave stock',1,0,0,0);
  27.   SIMEND(40.0);
  28.   CREATE(EX(2.0), CUSTMR);
  29.   c := 15;
  30.   TALLY(2,c);
  31. end;
  32.  
  33. procedure buying;
  34. begin
  35.   if c = 4 then CREATE(TR(5.0,7.0,9.0), GOODS);
  36.   if c > 0 then c := c - 1 else TALLY(1,1);
  37.   TALLY(2,c);
  38.   DISPOS;
  39. end;
  40.  
  41. procedure order;
  42. begin
  43.   c := c + 12;
  44.   TALLY(2,c);
  45.   DISPOS;
  46. end;
  47.  
  48. begin
  49.  
  50.   prime;
  51.  
  52.   repeat
  53.     ecode := NEXTEV;
  54.     if ecode > 0 then
  55.     begin
  56.       case ecode of
  57.  
  58.       ARRIVL: if IDE = CUSTMR then
  59.               begin
  60.                 CREATE(EX(2.0), CUSTMR);
  61.                 SCHED(0, TRYBUY, IDE);
  62.               end else
  63.                 SCHED(0, REPLNS, IDE);
  64.  
  65.       TRYBUY: buying;
  66.  
  67.       REPLNS: order;
  68.  
  69.       end;
  70.  
  71.     end;
  72.  
  73.   until ecode = 0;
  74.  
  75.   SUMRY('');
  76.  
  77. end.
  78.