/****************************************************************************/
/*                                                                          */
/*  BGBBS.REXX  -   Oh well Xenolink is in need of a new BBS lister so here */
/*      V0.2        it is. As XBBSLister hasn't been updated in yonks I     */
/* 10th November 96 thought I'd knock a new BBS lister up, hope you like it */
/*                                                                          */
/* (C)1996 Ben Gaunt Sysop: Channel X BBS +44 (0)181 943 5187               */
/*                     AKA: BenG OR Madness on IRC                          */
/*                    Fido: 2:254/260.12                                    */
/*                  e-mail: ben.gaunt@pickled.demon.co.uk                   */
/*                                                                          */
/* NEEDS:  T: to be assigned  (assign T: RAM:T) its in most start ups ;)    */
/*                                                                          */
/****************************************************************************/

/* Arguments:   BGBBS.REXX [NODE_NUMBER] */

/*************************************************************************/
/* I BEN GAUNT THE PROGRAMER OF THIS BBS LISTER REQUESTS THAT YOU DO NOT */
/* ALTER THE LINE DISPLAYING MY BBS NUMBER. AFTER ALL THIS DOOR IS       */
/* FREEWARE AND IT WOULD BE NICE FOR ME TO GET A REWARD OF A FEW NEW     */
/* USERS FOR MY TROUBLES. BUT IF YOU REALY DONT WANT TO HAVE MY NUMBER   */
/* THERE FEEL FREE TO REMOVE IT, IT WOULD BE NICE IF YOU WOULD KEEP IT   */
/* THERE THOUGH ;)                                                       */
/*************************************************************************/

OPTIONS RESULTS
arg Node_Number
Signal on error
signal on syntax
signal on IOERR
PortName = 'XenolinkRexxPort'Node_Number
GetUserVar Name
nicename result
uname$ = result
GetUserVar Privilege
alevel = result

GetUserVar PageLength
plength = result
dplength = plength - 8

Getvar 8
menuset=result

/* ======================================================================== */
/*  <<< CONFIGURATION >>>   <<< CONFIGURATION >>>   <<< CONFIGURATION >>>   */
/* ======================================================================== */

/* THE VALUE [0] BELOW SHOULD BE = TO FIRST MENUSET TO USE ANSI COLOUR */
/* 1 = USE ANSI + COLOUR, 0 = USE ASCII TEXT */

if menuset > 0 then do
 _ANSI = 1
end
else do
 _ANSI = 0
end


/* IF YOU WANT BGBBS IN A DIFFERENT LOCATION CHANGE THE PATH$ TO POINT TO */
/* THE NEW PATH. <<< IMPORTANT >>> THE PATH$ MUST END IN A : OR /         */

PATH$="REXX:BGBBS/"

/* ======================================================================== */
/*        <<< END CONFIGURATION >>>       <<< END CONFIGURATION >>>         */
/* ======================================================================== */

/* SET UP EASY COLOURS ;) */
 RED='[31m'
 GRE='[32m'
 YEL='[33m'
 BLU='[34m'
 PUR='[35m'
 CYA='[36m'
 OFF='[37m'

/* ======================================================================== */

CLS
message 'Loading BBS data, please wait a moment....'

call DATLOAD

/* ======================================================================== */

MAINMENU:

do forever

  call BANNER

  if _ANSI = 1 then do
    newline
    message RED'                          ['OFF'1'RED']'OFF' View the BBS list'
    message RED'                          ['OFF'2'RED']'OFF' Search BBS list'
    message RED'                          ['OFF'3'RED']'OFF' Download BBS list (ASCII TEXT)'
    message RED'                          ['OFF'4'RED']'OFF' Add a BBS to the list'
    message RED'                          ['OFF'5'RED']'OFF' Delete a BBS from the list'
    message RED'                          ['OFF'6'RED']'OFF' Help'
    newline
    message RED'                          ['OFF'7'RED']'OFF' Exit'
    newline
  end
  else do
    newline
    message '                          [1] View the BBS list'
    message '                          [2] Search BBS list'
    message '                          [3] Download BBS list (ASCII TEXT)'
    message '                          [4] Add a BBS to the list'
    message '                          [5] Delete a BBS from the list'
    message '                          [6] Help'
    newline
    message '                          [7] Exit'
    newline
  end

  msg '                            The choice is yours> '

  do until choice >0 & choice <8
    getchar
    choice=result
  end

  if choice = 1 then do
    call VIEWLIST
  end

  if choice = 2 then do
    call SEARCH
  end

  if choice = 3 then do
    call DOWN
  end

  if choice = 4 then do
    call NEWBBS
  end 
  
  if choice = 5 then do
    call KILL
  end

  if choice = 6 then do
    call HELP
  end

  if choice = 7 then do
    CLS
    exitscript
  end

end

/* ======================================================================== */

NEWBBS:

call BANNER
newline
/* GET BBS DETAILS */
n=totalBBS+1
if _ANSI = 1 then do
  msg GRE'           BBS name:'OFF
  getline 58 normal ' '
  BBS$.n.1 = result

  msg GRE'   Telephone number:'OFF
  getline 58 normal ' '
  BBS$.n.2 = result

  msg GRE'         Open hours:'OFF
  getline 58 normal ' '
  BBS$.n.3 = result

  msg GRE'      Max baud rate:'OFF
  getline 58 normal ' '
  BBS$.n.4 = result

  msg GRE'           Location:'OFF
  getline 58 normal ' '
  BBS$.n.5 = result

  msg GRE'       BBS Software:'OFF
  getline 58 normal ' '
  BBS$.n.6 = result

  msg GRE'       Sysop''s name:'OFF
  getline 58 normal ' '
  BBS$.n.7 = result

  msg GRE'      Mail Networks:'OFF
  getline 58 normal ' '
  BBS$.n.8 = result

  msg GRE'        Net address:'OFF
  getline 58 normal ' '
  BBS$.n.9 = result

  msg GRE'      Email address:'OFF
  getline 58 normal ' '
  BBS$.n.10 = result

  msg GRE'Computers supported:'OFF
  getline 58 normal ' '
  BBS$.n.11 = result

  msg GRE'      Comment (1/3):'OFF
  getline 58 normal ' '
  BBS$.n.12 = result

  msg GRE'      Comment (2/3):'OFF
  getline 58 normal ' '
  BBS$.n.13 = result

  msg GRE'      Comment (3/3):'OFF
  getline 58 normal ' '
  BBS$.n.14 = result

  message GRE'               Date: 'RED||date()||OFF
  BBS$.n.15 = date()
end
else do
  msg '           BBS name:'
  getline 58 normal ' '
  BBS$.n.1 = result

  msg '   Telephone number:'
  getline 58 normal ' '
  BBS$.n.2 = result

  msg '         Open hours:'
  getline 58 normal ' '
  BBS$.n.3 = result

  msg '      Max baud rate:'
  getline 58 normal ' '
  BBS$.n.4 = result

  msg '           Location:'
  getline 58 normal ' '
  BBS$.n.5 = result

  msg '       BBS Software:'
  getline 58 normal ' '
  BBS$.n.6 = result

  msg '       Sysop''s name:'
  getline 58 normal ' '
  BBS$.n.7 = result

  msg '      Mail Networks:'
  getline 58 normal ' '
  BBS$.n.8 = result

  msg '        Net address:'
  getline 58 normal ' '
  BBS$.n.9 = result

  msg '      Email address:'
  getline 58 normal ' '
  BBS$.n.10 = result

  msg 'Computers supported:'
  getline 58 normal ' '
  BBS$.n.11 = result

  msg '      Comment (1/3):'
  getline 58 normal ' '
  BBS$.n.12 = result

  msg '      Comment (2/3):'
  getline 58 normal ' '
  BBS$.n.13 = result

  msg '      Comment (3/3):'
  getline 58 normal ' '
  BBS$.n.14 = result

  message '               Date: 'RED||date()
  BBS$.n.15 = date()
end

QUERYN 'Is all the above correct?'
yn$ = result

/* IF DATA IS CORRECT ADD IT TO THE BBS LIST DAT FILE */
if yn$ = 'Y' then do

  BBS$.n.16 = uname$
  totalBBS=totalBBS+1

  newline
  msg 'Adding BBS details to the BBS list......'
  call open(datafile, PATH$||'BGBBS.DAT', 'a')
    call writeln(datafile, BBS$.n.1)
    call writeln(datafile, BBS$.n.2)
    call writeln(datafile, BBS$.n.3)
    call writeln(datafile, BBS$.n.4)
    call writeln(datafile, BBS$.n.5)
    call writeln(datafile, BBS$.n.6)
    call writeln(datafile, BBS$.n.7)
    call writeln(datafile, BBS$.n.8)
    call writeln(datafile, BBS$.n.9)
    call writeln(datafile, BBS$.n.10)
    call writeln(datafile, BBS$.n.11)
    call writeln(datafile, BBS$.n.12)
    call writeln(datafile, BBS$.n.13)
    call writeln(datafile, BBS$.n.14)
    call writeln(datafile, BBS$.n.15)
    call writeln(datafile, BBS$.n.16)
  call close(datafile)
  msg 'done.'
end
/* IF DATA ISNT CORRECT INFORM USER DATA HASNT BEEN ADDED TO THE LIST */
else do
  newline
  message 'Entry aborted BBS details have NOT been added to the list.'
  newline
  msg 'Press any key to continue.'
  getchar
end

return

/* ======================================================================== */

VIEWLIST:

call BANNER

if _ANSI = 1 then do
  newline
  message GRE'Would you like to see a 'RED'['OFF'S'RED']'GRE'hort quick list or a 'RED'['OFF'F'RED']'GRE'ull detailed list?'OFF
  newline
  msg RED'['OFF's'RED']'GRE'hort/'RED'['OFF'F'RED']'GRE'ull > 'OFF
end
else do
  newline
  message 'Would you like to see a [S]hort quick list or a [F]ull detailed list?'
  newline
  msg '[s]hort/[F]ull > '
end

getchar
lview$=result
lview$=upper(lview$)

if lview$ = 'S' then do
/* SHORT LISTER */

  pause = (plength-8)/5

/* do n=1 to totalBBS */
n=0
do until n >= totalBBS
    call banner
    counter = 0

    /* KEEP PRINTING THE BBS DATA UNTIL SCREEN IS FULL OR END OF FILE */
    /* HAS BEEN REACHED */
    /* THIS IS VERY VERY VERY MESSY :-/ */
    do until counter >= pause-1 | n = totalBBS

      newline
      counter = counter +1
      n=n+1

      if _ANSI = 1 then do
        message GRE'           BBS name: 'YEL||BBS$.n.1
        message GRE'   Telephone number: 'OFF||BBS$.n.2
        message GRE'         Open hours: 'OFF||BBS$.n.3
        message GRE'Computers supported: 'OFF||BBS$.n.11
      end
      else do
        message '           BBS name: '||BBS$.n.1
        message '   Telephone number: '||BBS$.n.2
        message '         Open hours: '||BBS$.n.3
        message 'Computers supported: '||BBS$.n.11
      end
    end

    newline
    msg '                  Press any key to continue or press Q to quit'
    getchar
    choice$=result
    upper choice$
    if choice$ = 'Q' then do
      n=totalBBS
    end

  end

end
else do
  /* FULL LISTER */
  do n=1 to totalBBS
    /* DISPLAY THE RECENTLY READ IN DATA */

    call banner

    /* DISPLAY THE BBS DETAILS */
    call DISPLAYBBS(n)

    /* LINE 16 ISNT SHOWN USED IN DEL OPTION */
    
    newline
    msg '                  Press any key to continue or press Q to quit'
    getchar
    choice$=result
    upper choice$
    if choice$ = 'Q' then do
      n=totalBBS
    end

  end

end

return

/* ======================================================================== */

DOWN:

call BANNER
newline
message 'Generating ASCII text file from the BBS lister data, please wait...'
newline

call open(introdata, PATH$||'INTRO.TXT', 'R')
call open(enddata, PATH$||'END.TXT', 'R')

call open(ASCII, 'T:BBS_LIST.TXT', 'W')

/* COPY INTRO TEXT TO ASCII FILE */
do until eof(introdata)
  aline$ = readln(introdata)
  call writeln(ASCII, aline$)
end

/* WRITE BBS LIST TO ASCII FILE */
do n=1 to totalBBS
  call writeln(ASCII, '           BBS name: '||BBS$.n.1)
  call writeln(ASCII, '   Telephone number: '||BBS$.n.2)
  call writeln(ASCII, '         Open hours: '||BBS$.n.3)
  call writeln(ASCII, '      Max baud rate: '||BBS$.n.4)
  call writeln(ASCII, '           Location: '||BBS$.n.5)
  call writeln(ASCII, '       BBS Software: '||BBS$.n.6)
  call writeln(ASCII, '       Sysop''s name: '||BBS$.n.7)
  call writeln(ASCII, '      Mail Networks: '||BBS$.n.8)
  call writeln(ASCII, '        Net address: '||BBS$.n.9)
  call writeln(ASCII, '      Email address: '||BBS$.n.10)
  call writeln(ASCII, 'Computers supported: '||BBS$.n.11)
  call writeln(ASCII, '            Comment: '||BBS$.n.12)
  call writeln(ASCII, '                     '||BBS$.n.13)
  call writeln(ASCII, '                     '||BBS$.n.14)
  call writeln(ASCII, 'Date placed on list: '||BBS$.n.15)
  call writeln(ASCII, '')
  call writeln(ASCII, '----------------------------------------------------------------------------')
  call writeln(ASCII, '')
end

/* COPY END TEXT TO ASCII FILE */
do until eof(enddata)
  aline$ = readln(enddata)
  call writeln(ASCII, aline$)
end

/* TAG IT ;) */
call writeln(ASCII, '          .----------------------------------------------------------.')
call writeln(ASCII, '          | This file was created with BG-BBS LISTER ©1996 Ben Gaunt |')
call writeln(ASCII, '          |         Another Pickled Fish Software Production!        |')
call writeln(ASCII, '          `----------------------------------------------------------''')

call close (ASCII)
call close (introdata)
call close (enddata)

  DOWNLOADFILE 'T:BBS_LIST.TXT'
  dl = result

  if dl = 1 then do
    message 'Download failed, local download not allowed!'
  end   

  if dl = 2 then do
    message 'Download failed, file does not exist?'
  end

  if dl = 3 then do
    message 'Download failed, file already marked for downloading!'
  end

newline
msg 'Press any key to continue'
getchar

return

/* ======================================================================== */

SEARCH:

call banner

newline
if _ANSI=1 then do
  Msg GRE'Search on 'RED'['OFF'S'RED']'GRE'ysop name or 'RED'['OFF'B'RED']'GRE'bs name? 'OFF'> '
end
else do
  Msg 'Search on [S]ysop name or [B]bs name? > '
end

getchar
choice$=upper(result)

/* SEARCH SYSOP NAMES */
if choice$ = 'S' then do

  newline
  newline
  msg 'Search for > '
  getline 58 normal
  findme$ = result
  upper findme$

  if length(findme$) > 0 then do

    do n = 1 to totalBBS

      /* RESET THE FOUND FLAG */
      found = 0

      /* CHECK FOR MATCH */

      sysop$ = upper(BBS$.n.7)
      z=length(sysop$)
      x=length(findme$)

      do i = 1 to z
        itsme$ = substr(sysop$,i,x)

        if itsme$ = findme$ then do
          found=1
        end

      end


      /* DISPLAY BBS DETAILS IF A MATCH IS FOUND */
      if found = 1 then do

        call banner
        newline
        call DISPLAYBBS(n)
        newline

        msg '                  Press any key to continue or press Q to quit'
        getchar
        quiter$=result
        upper quiter$
        if quiter$ = 'Q' then do
          n = totalBBS
        end

      end

    end

  end

end

/* SEARCH BBS NAMES */
if choice$ = 'B' then do

  newline
  newline
  msg 'Search for > '
  getline 58 normal
  findme$ = result
  upper findme$

  if length(findme$) > 0 then do

    do n = 1 to totalBBS

      /* RESET THE FOUND FLAG */
      found = 0

      /* CHECK FOR MATCH */

      sysop$ = upper(BBS$.n.1)
      z=length(sysop$)
      x=length(findme$)

      do i = 1 to z
        itsme$ = substr(sysop$,i,x)

        if itsme$ = findme$ then do
          found=1
        end

      end


      /* DISPLAY BBS DETAILS IF A MATCH IS FOUND */
      if found = 1 then do

        call banner
        newline
        call DISPLAYBBS(n)
        newline

        msg '                  Press any key to continue or press Q to quit'
        getchar
        quiter$=result
        upper quiter$
        if quiter$ = 'Q' then do
          n = totalBBS
        end

      end

    end

  end

end

return

/* ======================================================================== */

KILL:

call banner
newline

do n=1 to totalBBS

  /* SEE IF USER WISHING TO DELETE HAS ENTERD ANYTHING */
  if BBS$.n.16 = uname$ | alevel = 255 then do

    call displaybbs(n)
    newline
    QUERYN 'Delete this BBS record? '
    killme = upper(result)
    
    if killme = 'Y' then do
      
      newline
      msg 'Removing BBS details from list pleas wait...'
   
      call open(datafile, PATH$||'BGBBS.DAT', 'W')
      do a=1 to totalBBS

        if a ~= n then do
          call writeln(datafile, BBS$.a.1)
          call writeln(datafile, BBS$.a.2)
          call writeln(datafile, BBS$.a.3)
          call writeln(datafile, BBS$.a.4)
          call writeln(datafile, BBS$.a.5)
          call writeln(datafile, BBS$.a.6)
          call writeln(datafile, BBS$.a.7)
          call writeln(datafile, BBS$.a.8)
          call writeln(datafile, BBS$.a.9)
          call writeln(datafile, BBS$.a.10)
          call writeln(datafile, BBS$.a.11)
          call writeln(datafile, BBS$.a.12)
          call writeln(datafile, BBS$.a.13)
          call writeln(datafile, BBS$.a.14)
          call writeln(datafile, BBS$.a.15)
          call writeln(datafile, BBS$.a.16)
        end

      end
      call close(datafile)

      call DATLOAD

    end

    call banner
    newline

  end

end

message 'There are no more BBS records that can be deleted by you.'
newline
message 'If there is a BBS record on here you wish removed please leave a message'
message 'to the Sysop he/she can remove it for you.'
newline
message 'Press any key to continue'
getchar

return

/* ======================================================================== */

HELP:

call TEXT(help.txt)

return

/* ======================================================================== */

TEXT:
/* LOAD AND DISPLAY A ASCII TEXT FILE  ARGS [FILENAME] */
arg fname$

/* CHECK FILE EXISTS */
if exists(PATH$||fname$) then do
  l = 0

  /* OPEN FILE AND READ ALL LINES INTO DYNAMIC ARRAY */
  call open(ASCII_file, path$||fname$, 'r')
  /* RESET FILE POINTER TO BEGINING OF FILE */
  call SEEK(ASCII_file, 0, 'B')

  do until EOF(ASCII_file)
    l = l + 1
    ASCIIline$.l = readln(ASCII_file)
  end

  /* call close(fname$) */
  call close(ASCII_file)

  z=0
  x=0
  cls
  call Banner
  newline

  /* DISPLAY THE TEXT ONE SCREEN FULL AT A TIME */
  do a = 1 to l
    message ASCIIline$.a
    z=z+1
    x=x+1

    if z = dplength | x = l then do
      z = 0
      newline
      msg '                    [Return] to continue              [Q]uit'
      getchar
      erm = result

      /* IF 'Q' SELECTED QUIT THE LOOP */
      if upper(erm) = 'Q' then do
        a = l
      end
      /* IF MORE TEXT TO BE DISPLAYED RE-DRAW TITLE */
      else if a ~= l then do
        cls
        call Banner
        newline
/*        message a' 'l
        message ASCII_file
*/
      end

    end

  end
end
else do
  /* IF FILE WASN'T FOUND DISPLAY ERROR MESSAGE AND CONTINUE */
  cls
  message '< ERROR > Can not find 'PATH$||fname$' file to load!'
  newline
  message 'Press any key'
  getchar
end

return

/* ======================================================================== */

BANNER:

CLS
if _ANSI = 1 then do
  message YEL'[44m                    Another Pickled Fish Software Production                   [0;40m'
  message OFF'                    BG ËÍ» ËÍ» ÉÍ»   Ë   Ë ÉÍ» ÉË» ÉÍ» ËÍ»'
  message CYA'                       ÌÍ¹ ÌÍ¹ ÈÍ»   º   º ÈÍ»  º  ÌÍ  ÌË¼'
  message BLU'                       ÊÍ¼ ÊÍ¼ ÈÍ¼   ÈÍ¼ Ê ÈÍ¼  Ê  ÈÍ¼ ÊÈÍ V0.2'OFF
  message CYA'[44m Channel X +44 (0)181 943 5187 'YEL'(C)1996 Ben Gaunt'CYA' Channel X +44 (0)181 943 5187 [0;40m'
end
else do
  message '_____________________Another Pickled Fish Software Production__________________'
  message '                    BG  _  _  _          _  ___  __  _ '
  message '                       |_)|_)|_''  |   | |_''  |  |_  |_|'
  message '                       |_)|_)._|  |__ | ._|  |  |__ | \ V0.2'
  message '_______________________________________________________________________________'
end

return

/* ======================================================================== */

DISPLAYBBS:
arg zx
    if _ANSI = 1 then do
      newline
      message GRE'           BBS name: 'YEL||BBS$.zx.1
      message GRE'   Telephone number: 'OFF||BBS$.zx.2
      message GRE'         Open hours: 'OFF||BBS$.zx.3
      message GRE'      Max baud rate: 'OFF||BBS$.zx.4
      message GRE'           Location: 'OFF||BBS$.zx.5
      message GRE'       BBS Software: 'OFF||BBS$.zx.6
      message GRE'       Sysop''s name: 'OFF||BBS$.zx.7
      message GRE'      Mail Networks: 'OFF||BBS$.zx.8
      message GRE'        Net address: 'OFF||BBS$.zx.9
      message GRE'      Email address: 'OFF||BBS$.zx.10
      message GRE'Computers supported: 'OFF||BBS$.zx.11
      message GRE'            Comment: 'CYA||BBS$.zx.12
      message GRE'                     'CYA||BBS$.zx.13
      message GRE'                     'CYA||BBS$.zx.14
      message GRE'Date placed on list: 'RED||BBS$.zx.15||OFF
    end
    else do
      newline
      message '           BBS name: '||BBS$.zx.1
      message '   Telephone number: '||BBS$.zx.2
      message '         Open hours: '||BBS$.zx.3
      message '      Max baud rate: '||BBS$.zx.4
      message '           Location: '||BBS$.zx.5
      message '       BBS Software: '||BBS$.zx.6
      message '       Sysop''s name: '||BBS$.zx.7
      message '      Mail Networks: '||BBS$.zx.8
      message '        Net address: '||BBS$.zx.9
      message '      Email address: '||BBS$.zx.10
      message 'Computers supported: '||BBS$.zx.11
      message '            Comment: '||BBS$.zx.12
      message '                     '||BBS$.zx.13
      message '                     '||BBS$.zx.14
      message 'Date placed on list: '||BBS$.zx.15
    end

return

/* ======================================================================== */

DATLOAD:
/* SEE IF FILE EXISTS */
if exists(PATH$||'BGBBS.DAT') then do
  i=1
  n=1
  call open(datafile, PATH$||'BGBBS.DAT', 'R')

  do until EOF(datafile)
    BBS$.n.i = readln(datafile)
    i=i+1
    if i = 17 then do
      i=1
      n=n+1
    end
  end

  call close(datafile)
  totalBBS = n-1
end
else do
  msg 'No data file exists? Making a new one at > '
  msg PATH$||'BGBBS.DAT'

  /* OPEN DATA FILE AND ENTER DATA */
  call open(datafile, PATH$||'BGBBS.DAT', 'w')
    call writeln(datafile, 'Channel X BBS')
    call writeln(datafile, '0181 943 5187')
    call writeln(datafile, '24hrs')
    call writeln(datafile, '28800bps')
    call writeln(datafile, 'London, UK')
    call writeln(datafile, 'Xenolink')
    call writeln(datafile, 'Ben Gaunt')
    call writeln(datafile, 'Fido, Barnet etc')
    call writeln(datafile, 'N/A')
    call writeln(datafile, 'ben.gaunt@pickled.demon.co.uk')
    call writeln(datafile, 'Amiga')
    call writeln(datafile, 'An Amiga based BBS that was established in March 1995 and')
    call writeln(datafile, 'still running. Trouble connecting at 28800+ then disable')
    call writeln(datafile, 'Vfc. Whq for MiggyByte disk mag and Pickled Fish Software')
    daet$ = date()
    call writeln(datafile, daet$)
    call writeln(datafile, 'Ben Gaunt')
  call close(datafile)

  /* RE-READ THE DATA IN ;) */
  i=1
  n=1
  call open(datafile, PATH$||'BGBBS.DAT', 'R')

  do until EOF(datafile)
    BBS$.n.i = readln(datafile)
    i=i+1
    if i = 17 then do
      i=1
      n=n+1
    end
  end

  call close(datafile)
  totalBBS = n-1

end

return

/* ======================================================================== */

SYNTAX:
/* IF AN SYNTAX ERROR HAPPENS INFORM SYSOP */
CLS
message 'Syntax error in BGBBS...'
message 'Please inform the Sysop.'
message 'Error occured in line:' SIGL 
msg 'Press any key'
getchar
exit
