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_0501.BAS < prev    next >
BASIC Source File  |  1991-04-09  |  2KB  |  104 lines

  1. ' Program EX_0501.BAS
  2. ' Listing 9B - see documentation in TUTOR.SSS
  3.  
  4. const ARRIVL = 1, STARTA = 2, ENDACT = 3, NEXTAC = 4
  5. const STRTDY = 5
  6. const CLOSES = 0, WATCH = 1
  7. const FALSE = 0, TRUE = noT FALSE
  8.  
  9. common shared ecode, opens, repars
  10. common shared inter, rept
  11.  
  12. declare sub prime ()
  13. declare sub clshop ()
  14. declare sub newday ()
  15.  
  16. rem $include: 'SSSB.H'
  17.  
  18.   call prime
  19.  
  20.   do
  21.     ecode = NEXTEV
  22.     if ecode > 0 then
  23.       select case ecode
  24.  
  25.       case ARRIVL
  26.              if IDE = WATCH then
  27.                CREATE EX(inter), WATCH
  28.                SETA 1, T
  29.                SCHED 0, NEXTAC, WATCH
  30.              else
  31.                SCHED .5, STRTDY, CLOSES
  32.                clshop
  33.              end if
  34.  
  35.       case NEXTAC
  36.              if opens then
  37.                if repars then
  38.                  QUEUE 2, 0
  39.                else
  40.                  SCHED 0, STARTA, IDE
  41.                end if
  42.              else
  43.                QUEUE 1, 0
  44.              end if
  45.  
  46.       case STARTA
  47.              SCHED EX(rept), ENDACT, 0
  48.              repars = TRUE
  49.  
  50.       case ENDACT
  51.              QUEUE 3, 0
  52.              if NQ(2) > 0 then
  53.                REMVFQ 2, 1
  54.                SCHED 0, STARTA, 0
  55.              else
  56.                repars = FALSE
  57.              end if
  58.  
  59.       case STRTDY
  60.              newday
  61.  
  62.       end select
  63.     end if
  64.   loop while ecode > 0
  65.  
  66.   title$ = "  "
  67.   SUMRY sadd(title$)
  68.  
  69. sub clshop
  70.   opens = FALSE
  71.   do while NQ(3) > 0
  72.     REMVFQ 3, 1
  73.     TALLY 1, T - A(1)
  74.     DISPOS
  75.   loop
  76. end sub
  77.  
  78. sub newday
  79.   CREATE .5, CLOSES
  80.   DISPOS
  81.   opens = TRUE
  82.   repars = FALSE
  83.   do while (NQ(1))
  84.     REMVFQ 1, 1
  85.     QUEUE 2, 0
  86.   loop
  87. end sub
  88.  
  89. sub prime
  90.   INIQUE 3, 1, 1
  91.   title$ = "Sojourn time           "
  92.   INISTA 1, sadd(title$), 0, 10, 0, .2
  93.  
  94.   CREATE 0, WATCH
  95.   CREATE .5, CLOSES
  96.   SIMEND 10
  97.  
  98.   opens = TRUE
  99.   repars = FALSE
  100.   inter = 7 / 25
  101.   rept = 2 / 24
  102. end sub
  103.  
  104.