/*  $VER: CNet BINGO Ver 1.1  by Richard Horn  09-16-94         */
/*  DO NOT modify this program without the consent of Rick Horn */
/*       The Harbor Breeze BBS (C) 1993  (813) 855-9608         */
/*       CNet 3.05c Version                                     */

options results
bufferflush
signal on error
signal on syntax
signal on ioerr

getuser 1101745; muf=result

if muf = 1 then do
  bbscommand 'MU *'
end

changewhere "Bingo!"

transmit '@6}'  /* turn off word wrap and MORE */

logentry 'Played Bingo!'

rh=0
if ~exists('pfiles:bingo.cfg') then do
 transmit "n2cb Cannot find 'pfiles:BINGO.CFG', check documentation."
 signal quitnow
end
call open('infil','pfiles:bingo.cfg','R')
  BBS=readln('infil')
  SysOp=upper(readln('infil'))
  path=readln('infil')
  maxplays=readln('infil')
  maxturns=readln('infil')
  prz1=readln('infil')
  prz2=readln('infil')
  prz3=readln('infil')
  prz4=readln('infil')
  prz5=readln('infil')
  prz6=readln('infil')
  rh=1
  st=0
call close('infil')
if sourceline(307)~=sourceline(967) then do
  transmit 'cf'sourceline(2);signal quitnow
end
if ~exists(path||'lastmowin.dat') then do
  call open('lastfil',path||'lastmowin.dat','W')
  lastmonth = date(USA)
  lastline = lastmonth'|'No Previous winnner yet'|'0
  call writeln('lastfil',lastline)
  call close('lastfil')
end
call open('lastfil',path||'lastmowin.dat','R')
  transmit "f1n2cf    Last month's top BINGO money winner was:"
  lastline = readln('lastfil')
  parse var lastline lastdate'|'lastname'|'amount
  lastmonth = left(lastdate,2)
  transmit 'n1     ca 'lastname' ce...  $'amount
  sendstring 'w2}'
call close('lastfil')

/* Fixed variables - Do Not Change!  */
ver='CNet Bingo 1.1'          /* Current Program Version */
getuser 1                      /* Get users handle */
Handle = upper(result)
getuser 12                     /* Date/Time */
date=result
getuser 40                     /* User ID# */
userid=result
cls='f1'                      /* CNet 2.4+ CLS and Home MCI */
getuser 23
PTX=result                     /* Users Port number */
i=random(0,75,time('S'))        /* Initialize Random generator */
plays = 0
turns = 0
totcards = 0

call userinfo  /* Get users data from USER.DAT */

/* time to reset winners */
if lastmonth ~= left(date(USA),2) then call resetlast

if ((turns > maxturns) & (maxturns > 0)) then do
  if (handle = SysOp) then signal start
  transmit 'cbn3  You have played the maximum turns allowed for today...'
  transmit 'n1  Please try again tomorrow.'
  signal quickexit
end

START:
 transmit 'f1@6}'
 sendfile path||'bingo.start'
 sendstring 'f1n2caWould you like to see the current stats? (y/N) ?'
 getchar; a=result; call check
 if a = 'Y' then call stats
 snd = 0         /* Default to sound off */
 call nasties

START2:
plays = plays + 1
if ((plays > maxplays) & (maxplays > 0)) then do
  transmit 'cbn3  You have played the maximum cards for this turn...'
  signal quickexit
end

transmit 'f1@6}'
sendfile path||'select.ans'
sendstring '@6}'

SELECT:
sendstring 'f0!21}n1cf          Please make your game type selection (1-6,Q) ? '
getchar; a=result;call check
SAMEGAME:
if a='Q' then call quit
if a='1' then do
  type='Standard Bingo'
  game=1
  maxnums = random(20,50) 
  signal go
end
if a='2' then do
  type='Postage Stamp '
  game=2
  maxnums = random(40,60)
  signal go
end
if a='3' then do
  type='  Small - X - '
  game=3
  maxnums=random(40,60)
  signal go
end
if a='4' then do
  type='  Big   - L - '
  game=4
  maxnums=random(45,60)  /* 50,65 */
  signal go
end
if a='5' then do
  type='  Big   - X - '
  game=5
  maxnums=random(45,65)
  signal go
end
if a='6' then do
  type='  Cover All   '
  game=6
  maxnums=random(55,70)
  signal go
end
signal select

GO:
posB.1=1208
posB.2=1408
posB.3=1608
posB.4=1808
posB.5=2008
posEYE.1=1216
posEYE.2=1416
posEYE.3=1616
posEYE.4=1816
posEYE.5=2016
posN.1=1224
posN.2=1424
posN.4=1824
posN.5=2024
posG.1=1232
posG.2=1432
posG.3=1632
posG.4=1832
posG.5=2032
posO.1=1240
posO.2=1440
posO.3=1640
posO.4=1840
posO.5=2040

REDRAW:
call drawscreen1

INIT:
/* unused numbers have the value of "0", used will have a value of "1" */
do x=1 to 75
   used.x = 0
end

SELECTGAME:
count=0

/* Init new card */
do i=1 to 5
  B.i = 0
  BU.i = 0
  EYE.i = 0
  EYEU.i = 0
  N.i = 0
  NU.i = 0
  G.i = 0
  GU.i = 0
  O.i = 0
  OU.i = 0
end

call drawscreen2
 
GETCARDNUMS:
Bnums=0
EYEnums=0
Nnums=1
Gnums=0
Onums=0
 
GETB:
if bnums>4 then signal GETEYE
pick=random(1,15)
do i=1 to 5
  if B.i = pick then signal GETB
end
do i=1 to 5
  if (B.i = 0) then do
    B.i = pick
    Bnums=Bnums+1
    sendstring 'z2c0'
    call putnum
    signal GETB   
  end
end

GETEYE:
if EYEnums>4 then signal GETN
pick=random(16,30)
do i=1 to 5
  if EYE.i = pick then signal GETEYE
end
do i=1 to 5
  if (EYE.i = 0) then do
    EYE.i = pick
    EYEnums=EYEnums+1
    sendstring 'z2c0'
    call putnum
    signal GETEYE   
  end
end

N.3=99
NU.3=1

GETN:
if Nnums>4 then signal GETG
pick=random(31,45)
do i=1 to 5
  if i = 3 then iterate
  if N.i = pick then signal GETN
end
do i=1 to 5
  if i = 3 then iterate
  if (N.i = 0) then do
    N.i = pick
    Nnums=Nnums+1
    sendstring 'z2c0'
    call putnum
    signal GETN   
  end
end

GETG:
if Gnums>4 then signal GETO
pick=random(46,60)
do i=1 to 5
  if G.i = pick then signal GETG
end
do i=1 to 5
  if (G.i = 0) then do
    G.i = pick
    Gnums=Gnums+1
    sendstring 'z2c0'
    call putnum
    signal GETG   
  end
end

GETO:
if Onums>4 then signal playit
pick=random(61,75)
do i=1 to 5
  if O.i = pick then signal GETO
end
do i=1 to 5
  if (O.i = 0) then do
    O.i = pick
    Onums=Onums+1
    sendstring 'z2c0'
    call putnum
    signal GETO   
  end
end

PUTNUM:
if ((pick / 15) > 4) then do
  transmit 'f0!'left(posO.i,2)'}>'right(posO.i,2)'}'right(pick,2,' ')
  return
end
if ((pick / 15) > 3) then do
  transmit 'f0!'left(posG.i,2)'}>'right(posG.i,2)'}'right(pick,2,' ')
  return
end
if ((pick / 15) > 2) then do
  transmit 'f0!'left(posN.i,2)'}>'right(posN.i,2)'}'right(pick,2,' ')
  return
end
if ((pick / 15) > 1) then do
  transmit 'f0!'left(posEYE.i,2)'}>'right(posEYE.i,2)'}'right(pick,2,' ')
  return
end
if (pick < 16) then do
  transmit 'f0!'left(posB.i,2)'}>'right(posB.i,2)'}'right(pick,2,' ')
end
return

PLAYIT:
sendstring 'f0>24}z7c4 ***  'type'  *** '
sendstring 'f0!9}>55}z4c7 <S>ound = OFF       z0'
sendstring 'f0!22}z0c2            Use this card (Y/n) ? '
getchar;a=result;if result = 'N' then signal init
transmit 'n1^1}                                                    '
sendstring '^1}'
call check
signal playit2
signal quickexit

PLAYIT2:
if count > maxnums then call lost
sendstring 'f0!7}>23}z4c6 Your total winnings:  ce$'winnings'z0'
call getanumber
call checkused
call putused
sendstring 'f0!22}b'snd'      c2The caller yells...  cf'letter' - 'pick'                H15}'
STAYHERE:
getchar;a=result;call check
if a='Q' then call quit
if a='M' then call markit
if a='X' then call missed
if a='B' then call bingo
if a=' ' then signal playit2
if a='S' then call soundoff
signal stayhere

SOUNDOFF:
snd = (snd = 0)
if snd = 1 then do
  sendstring 'f0!9}>55}z4c7 <S>ound = ON        z0'
  sendstring 'f0!22}>34}'
end
if snd = 0 then do
  sendstring 'f0!9}>55}z4c7 <S>ound = OFF       z0'
  sendstring 'f0!22}>34}'
end
return

MARKIT:
if letter = 'O' then do
  do i = 1 to 5
    if O.i = pick then do
      sendstring 'z2cf'
      O.i = pick
      OU.i = 1
      call putnum
      sendstring 'z0'
      return
    end
  end
  call saynot
  return
end
if letter = 'G' then do
  do i = 1 to 5
    if G.i = pick then do
      sendstring 'z2cf'
      G.i = pick
      GU.i = 1
      call putnum
      sendstring 'z0'
      return
    end
  end
  call saynot
  return
end
if letter = 'N' then do
  do i = 1 to 5
    if N.i = pick then do
      sendstring 'z2cf'
      N.i = pick
      NU.i = 1
      call putnum
      sendstring 'z0'
      return
    end
  end
  call saynot
  return
end
if letter = 'I' then do
  do i = 1 to 5
    if EYE.i = pick then do
      sendstring 'z2cf'
      EYE.i = pick
      EYEU.i = 1
      call putnum
      sendstring 'z0'
      return
    end
  end
  call saynot
  return
end
if letter = 'B' then do
  do i = 1 to 5
    if B.i = pick then do
      sendstring 'z2cf'
      B.i = pick
      BU.i = 1
      call putnum
      sendstring 'z0'
      return
    end
  end
  call saynot
  return
end
return

SAYNOT:
  sendstring 'f0!22}                                                         '
  sendstring 'f0!22}>20}z0cbNot on card!b'snd'w1}'
  sendstring 'f0!22}b'snd'      c2Last number was...   o1cf'letter' - 'pick'o0                H15}'
return

MISSED:
query 'f0!22}b'snd'       c2What number did you miss?        H7}';call getnum
temp = pick
lettemp = letter
pick = ans
if used.pick = 1 then do
  call putused
  call markit
  pick = temp
  letter = lettemp
  sendstring 'f0!22}b'snd'      c2Last number was...   o1cf'letter' - 'pick'o0                H15}'
  return
end
pick = temp
letter = lettemp
sendstring 'f0!22}b'snd'      cbThat number was NOT called yet!w1}'
sendstring 'f0!22}b'snd'      c2Last number was...   o1cf'letter' - 'pick'o0                H15}'
return

BINGO:
if game=1 then do           /* standard bingo */
  if (BU.1 = 1) & (BU.2 = 1) & (BU.3 = 1) & (BU.4 = 1) & (BU.5 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (EYEU. 1 = 1) & (EYEU.2 = 1) & (EYEU.3 = 1) & (EYEU.4 = 1) & (EYEU.5 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (NU.1 = 1) & (NU.2 = 1) & (NU.4 = 1) & (NU.5 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (GU.1 = 1) & (GU.2 = 1) & (GU.3 = 1) & (GU.4 = 1) & (GU.5 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (OU.1 = 1) & (OU.2 = 1) & (OU.3 = 1) & (OU.4 = 1) & (OU.5 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (BU.1 = 1) & (EYEU.1 = 1) & (NU.1 = 1) & (GU.1 = 1) & (OU.1 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (BU.2 = 1) & (EYEU.2 = 1) & (NU.2 = 1) & (GU.2 = 1) & (OU.2 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (BU.3 = 1) & (EYEU.3 = 1) & (GU.3 = 1) & (OU.3 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (BU.4 = 1) & (EYEU.4 = 1) & (NU.4 = 1) & (GU.4 = 1) & (OU.4 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (BU.5 = 1) & (EYEU.5 = 1) & (NU.5 = 1) & (GU.5 = 1) & (OU.5 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (BU.1 = 1) & (EYEU.2 = 1) & (GU.4 = 1) & (OU.5 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
  if (BU.5 = 1) & (EYEU.4 = 1) & (GU.2 = 1) & (OU.1 = 1) then do
    amount = prz1
    winnings = (winnings + amount)
    signal win
  end
end
if game=2 then do           /* Postage Stamp */
  if (BU.1 = 1) & (BU.2 = 1) & (EYEU.1 = 1) & (EYEU.2 = 1) then do
    amount = prz2
    winnings = (winnings + amount)
    signal win
  end
  if (BU.4 = 1) & (BU.5 = 1) & (EYEU.4 = 1) & (EYEU.5 = 1) then do
    amount = prz2
    winnings = (winnings + amount)
    signal win
  end
  if (GU.1 = 1) & (GU.2 = 1) & (GU.2 = 1) & (OU.2 = 1) then do
    amount = prz2
    winnings = (winnings + amount)
    signal win
  end
  if (GU.4 = 1) & (GU.5 = 1) & (OU.4 = 1) & (OU.5 = 1) then do
    amount = prz2
    winnings = (winnings + amount)
    signal win
  end
end
if game=3 then do           /* Small - X - */
  if (EYEU.2 = 1) & (GU.2 = 1) & (EYEU.4 = 1) & (GU.4 = 1) then do
    amount = prz3
    winnings = (winnings + amount)
    signal win
  end
end
if game=4 then do          /* Big - L -  */
  L1 = 0
  L2 = 0
  L3 = 0
  L4 = 0
  ytotal = (BU.1 + BU.2 + BU.3 + BU.4 + BU.5)
  xtotal = (EYEU.5 + NU.5 + GU.5 + OU.5)
  L1 = (ytotal + xtotal)
  ytotal = (OU.1 + OU.2 + OU.3 + OU.4 + OU.5)
  xtotal = (BU.1 + EYEU.1 + NU.1 + GU.1)
  L2 = (ytotal + xtotal)
  ytotal = (OU.1 + OU.2 + OU.3 + OU.4 + OU.5)
  xtotal = (EYEU.5 + NU.5 + GU.5 + OU.5)
  L3 = (ytotal + xtotal)
  ytotal = (BU.1 + BU.2 + BU.3 + BU.4 + BU.5)
  xtotal = (EYEU.1 + NU.1 + GU.1 + OU.1)
  L4 = (ytotal + xtotal)
  if (L1 = 9) then do    
    amount = prz4
    winnings = (winnings + amount)
    signal win
  end
  if (L2 = 9) then do    
    amount = prz4
    winnings = (winnings + amount)
    signal win
  end
  if (L3 = 9) then do    
    amount = prz4
    winnings = (winnings + amount)
    signal win
  end
  if (L4 = 9) then do    
    amount = prz4
    winnings = (winnings + amount)
    signal win
  end
end
if game=5 then do          /* Big - X -  */
  ytotal = (BU.1 + EYEU.2 + GU.4 + OU.5)
  xtotal = (OU.1 + GU.2 + EYEU.4 + BU.5)
  if (ytotal + xtotal = 8) then do    
    amount = prz5
    winnings = (winnings + amount)
    signal win
  end
end
if game=6 then do          /* Cover All */
  total = 0
  NU.3 = 1
  do i=1 to 5
    total = (total + BU.i)
  end
  do i=1 to 5
    total = (total + EYEU.i)
  end
  do i=1 to 5
    total = (total + NU.i)
  end
  do i=1 to 5
    total = (total + GU.i)
  end
  do i=1 to 5
    total = (total + OU.i)
  end
  if (total = 25) then do
    amount = prz6
    winnings = (winnings + amount)
    signal win
  end
end
sendstring 'f0!22}      cb  Sorry, no BINGO yet...               H15}W1}'
sendstring 'f0!22}b'snd'      c2Last number was...   o1cf'letter' - 'pick'o0                H15}'
return

WIN:
sendstring 'f0!22}>5}                                        H40}'
sendstring '>10}o1cfYou Wonc9 w1}b'snd'! w1}b'snd'! w1}b'snd'!   ce$cf'amount'.00o0w1}'
sendstring 'c2          Press any key...g1'
signal playagain

LOST:
lose = random(1,10)
sendstring 'f0!22}b'snd'      cb'nasty.lose'b'snd'w1}b'snd'w1}b'snd'w2}'


PLAYAGAIN:
sendstring 'f0!22}                                                                           '
sendstring 'f0!22}z0cd            Play again c7(cdYc7/c5nc7)cd ?             H13}'
getchar;a=result;if result = 'N' then call quit
transmit 'n1^1}                                                    '
sendstring '^1}'
call check
sendstring 'f0!22}z0cd            Same Game type c7(cdYc7/c5nc7)cd ?             H13}'
getchar;a=result;if result = 'N' then signal start2
transmit 'n1^1}                                                    '
sendstring '^1}'
call check
a=game
signal samegame

GETANUMBER:
pick = random(1,75)
return

CHECKUSED:
if used.pick = 1 then do
   pick = random(1,75)
   signal checkused
end
used.pick = 1
count=count+1
return

PUTUSED:
if ((pick / 15) > 4) then do
  move = (4*(pick-60))+6
  transmit 'f0!6}>'move'}c7'right(pick,2,' ')
  letter = 'O'
  return
end
if ((pick / 15) > 3) then do
  move = (4*(pick-45))+6
  transmit 'f0!5}>'move'}c7'right(pick,2,' ')
  letter = 'G'
  return
end
if ((pick / 15) > 2) then do
  move = (4*(pick-30))+6
  transmit 'f0!4}>'move'}c7'right(pick,2,' ')
  letter = 'N'
  return
end
if ((pick / 15) > 1) then do
  move = (4*(pick-15))+6
  transmit 'f0!3}>'move'}c7'right(pick,2,' ')
  letter = 'I'
  return
end
if (pick < 16) then do
  move = (4*(pick))+6
  transmit 'f0!2}>'move'}c7'right(pick,2,' ')
  letter = 'B'
end
return


DRAWSCREEN1:
 sendfile path||'board.mci'
 sendstring '@6}'
return
 
DRAWSCREEN2:
 sendfile path||'card.mci'
 sendstring '@6}'
return

TOPFIVE:    /* Get the top five scores */
if ~exists(path||'user.dat') then do
  transmit='No winners yet'
  return
end
n = 0
call open('topfil',path||'user.dat','R')
do while ~EOF('topfil')
  n =(n + 1)
  temptop.n = readln('topfil')
  parse var temptop.n tempname.n'|'tempscore.n'|'junka'|'junkb'|'junkc
end
call close('topfil')

do i = 1 to (n-1)
  do j = (i+1) to n
    if (tempscore.i < tempscore.j) then do
      temptop = tempscore.i
      tempscore.i = tempscore.j
      tempscore.j = temptop
      temptop = tempname.i
      tempname.i = tempname.j
      tempname.j = temptop
    end
  end
end
transmit 'f1!4}ce                    * * * cf Top Five Bingo Winnersce  * * *'
transmit ' '
do i=1 to (n-1)
  if i > 5 then leave
  transmit 'c'i+1'                         'left(tempname.i,20,'.')' $'tempscore.i
end 
return

USERINFO:  /* handle | Tot won | Tot cards | turns today | lastdate-played */ 
if ~exists(path||'user.dat') then do
  call open('userout',path||'user.dat','W')
    call writeln('userout',handle'|'0'|'0'|'0'|'date('USA'))
  call close('userout')
end
found = 0
call open('userin',path||'user.dat','R')
  do until (EOF('userin') = 1)
    templine=readln('userin')
    parse var templine thandle'|'twon'|'tcards'|'tturns'|'tlastplay
    if thandle = handle then do
      found = 1
      winnings = twon
      totcards = tcards
      if tlastplay ~= date('USA') then do
        turns = 0
      end
      if tlastplay = date('USA') then do
        turns = tturns
      end
      leave
    end
  end
  if found = 0 then do
    winnings = 0
    tcards = 0
    turns = 0
  end
call close('userin')
return

SAVEUSER:
totcards = totcards + plays
i=0
saved = 0
call checkbusy
call busy
call open('savein',path||'user.dat','R')
  do until (EOF('savein') = 1)
    i = i + 1
    saveline.i = readln('savein')
    parse var saveline.i thandle'|'oldwon'|'oldcards'|'oldturns'|'oldlast
    if thandle = handle then do
      saveline.i = handle'|'winnings'|'totcards'|'turns'|'date('USA')
      saved = 1
    end
  end
call close('savein')
if saved = 1 then do
  call open('saveout',path||'user.dat','W')
  do line=1 to i-1
    call writeln('saveout',saveline.line)
  end
end
if saved = 0 then do
  call open('saveout',path||'user.dat','A')
  userline = handle'|'winnings'|'totcards'|'turns'|'date('USA')
  call writeln('saveout',userline)
end
call close('saveout')
call unbusy
call topfive
return

RESETLAST:
transmit 'cf  Updating monthly records and reseting winners list...'
n = 0
call open('topfil',path||'user.dat','R')
do while ~EOF('topfil')
  n = (n + 1)
  temptop.n = readln('topfil')
  parse var temptop.n tempname.n'|'tempscore.n'|'junka'|'junkb'|'junkc
end
call close('topfil')

do i = 1 to (n-1)
  do j = (i+1) to n
    if (tempscore.i < tempscore.j) then do
      temptop = tempscore.i
      tempscore.i = tempscore.j
      tempscore.j = temptop
      temptop = tempname.i
      tempname.i = tempname.j
      tempname.j = temptop
    end
  end
end

call open('lastfil',path||'lastmowin.dat','W')
  lastline = date(USA)'|'tempname.1'|'tempscore.1
  call writeln('lastfil',lastline)
call close('lastfil')
/* reset winners list */
sendstring 'w2}'
address command 'delete 'path||'user.dat'
call userinfo
return

STATS:
if ~exists(path||'user.dat') then do
  transmit='caThere are No winners yet... w2}'
  return
end
n = 0
call open('statfil',path||'user.dat','R')
do while ~EOF('statfil')
  n =(n + 1)
  statline.n = readln('statfil')
  parse var statline.n statname.n'|'statscore.n'|'statcards.n'|'junkb'|'junkc
end
call close('statfil')

do i = 1 to (n-1)
  do j = (i+1) to n
    if (statscore.i < statscore.j) then do
      stattop = statscore.i
      statscore.i = statscore.j
      statscore.j = stattop
      stattop = statname.i
      statname.i = statname.j
      statname.j = stattop
      stattop = statcards.i
      statcards.i = statcards.j
      statcards.j = stattop
    end
  end
end
transmit 'f1!5}ce               * * * cf Current Bingo Winnersce  * * *'
transmit 'n1              caHandlecd           Cards Playedce  Winningscf'
transmit '           -------------        ----------   --------'
do i=1 to (n-1)
  transmit 'ca           'left(statname.i,20,'.')'cd   'left(statcards.i,6,'.')'      ce$'statscore.i
end 
sendstring 'n1c2                         Press any key...g1'
st=1
return

NASTIES:   /* Get other winners lines */
if ~exists(path||'wins.txt') then do
 transmit "n2cb Cannot find 'WINS.TXT', please inform sysop."
 do i=1 to 10
   nasty.i = 'The lady in the back got a bingo...'
 end
 return
end
call open('nastin',path||'wins.txt','R')
  do i=1 to 10
    nasty.i = readln('nastin')
  end
call close('nastin')
return

CHECKBUSY:  /* is another port writing now? */
hmm = 0
sendstring '.....'
KEEPGOING:
if exists(path||'busy') then do
   do d=1 to 1000
   end
   hmm = hmm + 1
   sendstring '.'
   if hmm > 52 then signal unbusy
   signal keepgoing
end
return

BUSY:  /* seize the port */
call checkbusy
call open('fil',path||'busy','W')
  call writeln('fil','I am busy')
call close('fil')
return

UNBUSY:  /* release the port */
address command 'delete 'path||'busy'
return

GETANS:
ans=upper(result)
 if ans='###PANIC' then signal Quickexit
return

QUIT:
sendstring 'f0!22}                                                          '
sendstring 'n1^1}>10}c2You cereally c2want to cbQUITc2? (caYc2/cbnc2)ca: '
getchar; a=result
if a='N' then do
   sendstring 'f0!22}b'snd'      c2Last number was...   o1cf'letter' - 'pick'o0                H15}'
   return
end
transmit 'caYes!w1}'; call Quickexit

CHECK:
if a='###PANIC' then signal quickexit
return

GETNUM:
ans=result
 if ans='###PANIC' then signal Quickexit
return

QUICKEXIT:
 turns = turns + 1
 transmit 'f1cfThanks for playing BBS-BINGO...w1}'
 call saveuser
 call hbad
 transmit 'n1Returning to the 'BBS'...'
 if muf = 1 then do
   bbscommand 'MU *'
 end
 bufferflush
 shutdown
 exit

QUITNOW:
 transmit 'n1Returning to the BBS...'
 bufferflush
 shutdown
 exit

HBAD:
transmit 'n3            z4cf           'ver' written by Boss            z0'
transmit '            z4ce Harbor Breeze BBS (813) 855-9608 CLink 911:6005/0.0 z0q1'
return

/*      ERROR HANDLING ----------------  */

IOERR:
  Transmit '*BOOM* Got an IO error line #'sigl' Code 'RC
  transmit 'Please inform the SysOp'
  call quickexit
exit

ERROR:
  Transmit '*BOOM* Got an error line #'sigl' Code 'RC
  transmit 'Please inform the SysOp'
  call quickexit
exit

SYNTAX:
  Transmit '*BOOM* Got a Syntax error, line #'sigl' Code 'RC
  transmit 'Please inform the SysOp'
  call quickexit
exit
