home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / XTALK1.ZIP / ANSWER.XWS < prev    next >
Encoding:
Text File  |  1990-04-30  |  21.0 KB  |  718 lines

  1. /*
  2.     Crosstalk for Windows Answer Mode Script
  3.  
  4.     This script provides an unattended 'answer mode' to answer outside calls.  
  5.     The NetID is used by this script to limit callers to a specific directory.  
  6.  
  7.     Copyright (C) 1989, 1990 Digital Communications Associates, Inc.
  8.     All Rights Reserved.
  9.  
  10.     Version 1.00 07-17-89 PJL
  11.     Version 1.01 01-04-90 PJL
  12.     Version 1.1  04-04-90 PJL
  13. */
  14.  
  15.  
  16. -- USER DEFINABLE OPTIONS VARIABLES
  17.     string Logfile, DirRestrict, Permission
  18.     Logfile = ''
  19.     DirRestrict = 0
  20.     Permission = '112111'
  21.  
  22. /* Logfile:    tells ANSWER what file to use for logging calls.
  23.         Set to null, ANSWER will not log calls.
  24.  
  25.    DirRestrict: set to 1 to restrict callers to one specific directory.  
  26.         Put directory name in the NetID session variable.
  27.         If DirRestrict = 1 and NetID is blank, ANSWER will restrict
  28.         the caller to the DIRFIL directory.
  29.  
  30.    Permission:    tells ANSWER which commands the caller may issue.
  31.         This string has six bytes, one for each command (except
  32.         for Bye and Help, which are always allowed) as follows:
  33.  
  34.     byte 1  -  Send (Crosstalk sends file to caller)
  35.         1 for yes, 0 for no
  36.  
  37.     byte 2  -  Receive (Crosstalk receives file from caller)
  38.         1 for yes, 0 for no
  39.  
  40.     byte 3  -  Protocol (get and/or set current protocol)
  41.         0 = disables command
  42.         1 = caller can see current protocol setting, but can't
  43.             change it.
  44.         2 = caller can change protocol setting remotely.
  45.  
  46.     byte 4  -  Type (upload a text file to caller)
  47.         1 for yes, 0 for no
  48.  
  49.     byte 5  -  Dir (send directory listing to caller)
  50.         1 for yes, 0 for no
  51.  
  52.     byte 6  -  Chdir (change current drive/directory)
  53.         1 for yes, 0 for no
  54.         (Automatically set to 0 if DirRestrict = 1)
  55. */
  56.  
  57.  
  58. -- global variables:
  59.     string rs232_str, rs232_char, pword, capname
  60.     string cdate, ctime, fstr, fname, ans
  61.     integer cmd_on, time_out, sav_speed
  62.  
  63.  
  64. -- constants:
  65.     integer ctrlc, bskey, crkey, esckey, spkey, delchr
  66.     ctrlc  = 3
  67.     bskey  = 8
  68.     crkey  = 13
  69.     esckey = 27
  70.     spkey  = 32
  71.     delchr = 127
  72.  
  73. -- reply strings:
  74.     EOLN = chr(13) + chr(10)
  75.     XTANS = 'Crosstalk for Windows Answer '
  76.     WAIT_MSG = XTANS + 'waiting for calls ...'
  77.     XTALK_MSG = XTANS + ' -  Press Control-C for Command prompt'
  78.     CMDS_ARE = 'Available commands are:'
  79.     CMD_SET = 'Send Receive Protocol Type Dir Chdir Bye Help'
  80.     PROTS = 'Available protocols are: CROSSTALK, DART, Xmodem, ' + ...
  81.         'Xmodem/CRC,' + EOLN + ...
  82.         '                         Xmodem/1K, Ymodem/Batch, Zmodem, Kermit'
  83.     PLEASE = 'Please initiate ' : REM_SYS = ' command on your system ...'
  84.     INIT_SEND = PLEASE + 'Send' + REM_SYS
  85.     INIT_RECV = PLEASE + 'Receive' + REM_SYS
  86.     INIT_REQU = PLEASE + 'Request' + REM_SYS
  87.  
  88.  
  89. -- code:
  90.     -- check Restriction level
  91.     if DirRestrict then {
  92.         Permission = inject(Permission,'0',6)
  93.         if length(NetID) then {
  94.             if upcase(left(NetID,2)) <> curdrive then ...
  95.                 drive left(NetID)
  96.             DirFil = NetID : chdir NetID
  97.         }
  98.     }
  99.  
  100.     cls
  101.     trap on
  102.     Echo = off
  103.     message '   Press Esc to end Answer'
  104.  
  105.     -- go directly to command mode if direct-connect
  106. label CHECK_LOCAL
  107.     if Local then {
  108.         go
  109.         reply EOLN;XTALK_MSG;EOLN;EOLN;
  110.         gosub GET_CMD
  111.         goto CHECK_LOCAL
  112.     }
  113.  
  114.     -- else set up modem
  115.     print at 13,25, 'ANSWER.XWS setting up modem ...'
  116.     Display = off : go
  117.     wait 5 ticks : reply
  118.     wait 5 ticks : reply ModemInit
  119.     wait 5 ticks : reply AnswerSetup
  120.     wait 5 ticks : Display = on
  121.     print at 13,15, WAIT_MSG
  122.     Display = off
  123.     if length(Logfile) then gosub OPEN_LOG
  124.  
  125.     sav_speed = Speed
  126. label WAIT_FOR_CALLS
  127.     Speed = sav_speed
  128.     while not Online
  129.         if inkey = esckey then goto RESET_MODEM
  130.         e = error
  131.     wend
  132.     watch 2 seconds for
  133.         'CONNECT 110'  : if ModemChange then Speed 110
  134.         'CONNECT 300'  : if ModemChange then Speed 300
  135.         'CONNECT 600'  : if ModemChange then Speed 600
  136.         'CONNECT 1200' : if ModemChange then Speed 1200
  137.         'CONNECT 2400' : if ModemChange then Speed 2400
  138.         'CONNECT 4800' : if ModemChange then Speed 4800
  139.         'CONNECT 9600' : if ModemChange then Speed 9600
  140.         'CONNECT'      : 
  141.     endwatch
  142.     cmd_on = false
  143.     cls : Display = on
  144.     reply EOLN;XTALK_MSG;EOLN;EOLN;
  145.     gosub ANSWER_CALL
  146.     message '   Press Esc to end Answer'
  147.     cls : go
  148.     print at 13,15, WAIT_MSG
  149.     Display = off
  150.     goto WAIT_FOR_CALLS
  151.  
  152.  
  153. LABEL ANSWER_CALL
  154.     cdate = date : ctime = time
  155.     if null(Password) then goto GET_CMD
  156.     try = 0
  157.     wait 1 second
  158. LABEL GET_PWORD
  159.     reply EOLN;'Password: ';
  160.     if try = 0 then reply chr(5);
  161.     print : print 'Password: ';
  162.     pword = ''
  163.     nextline pword, 120, 40
  164.     if pword = Password then {
  165.         reply EOLN;'Password accepted; please proceed.';EOLN;
  166.         print : print 'Password accepted; please proceed.'
  167.         goto GET_CMD
  168.     }
  169.     try = try + 1
  170.     if try = 3 then {
  171.         reply EOLN;'Bad Password: Access Denied.';EOLN;
  172.         print : print 'Bad Password: Access Denied.'
  173.         gosub END_CALL
  174.     }
  175.     goto GET_PWORD
  176.  
  177. LABEL GET_CMD
  178.     gosub ERROR_CHECK
  179.     rs232_str = ''
  180.     if cmd_on then reply 'Command: '; : print 'Command: ';
  181.     time_out = (60*curminute) + cursecond + 180
  182.  
  183. LABEL GET_CHAR
  184.     gosub ERROR_CHECK
  185.  
  186.     -- check for outgoing chars
  187.     k = inkey
  188.     if k <> 0 then ...
  189.         if k = crkey then print : reply EOLN;
  190.         else if k = esckey then gosub CHECK_BYE
  191.         else print chr(k); : reply chr(k);
  192.  
  193.     -- check for incoming chars
  194.     rs232_char = nextchar
  195.     if null(rs232_char) then {
  196.         cur_time = 60*curminute + cursecond
  197.         if cur_time >= time_out and not Local then gosub END_CALL
  198.         else goto GET_CHAR
  199.         }
  200.  
  201.     ch = asc(rs232_char) & 127
  202.  
  203.     -- Control-C ?
  204.     if ch = ctrlc then {
  205.         reply EOLN; : print
  206.         cmd_on = true
  207.         goto GET_CMD
  208.     }
  209.  
  210.     -- Carriage Return ?
  211.     if ch = crkey then {
  212.         if Newline then rs232_char = nextchar
  213.         print : reply EOLN;
  214.         gosub WHICH_CMD
  215.         goto GET_CMD
  216.     }
  217.  
  218.     -- Backspace ?
  219.     if ch = bskey or ch = delchr then {
  220.         if not null(rs232_str) then {
  221.             reply chr(bskey);
  222.             x = xpos - 2
  223.             print at ypos,x+1, ' ';
  224.             print at ypos,x, winstring(ypos,x,1);
  225.             rs232_str = left(rs232_str,length(rs232_str)-1)
  226.         }
  227.         goto GET_CHAR
  228.     }
  229.  
  230.     -- printable char ?  Toss it if not.
  231.     if ch < spkey or ch >= delchr then goto GET_CHAR
  232.     else {
  233.         print rs232_char;
  234.         reply rs232_char;
  235.         rs232_str = rs232_str + rs232_char
  236.     }
  237.  
  238.     -- check length of string
  239.     if length(rs232_str) >= 68 then {
  240.         print : reply EOLN;
  241.         gosub WHICH_CMD
  242.         goto GET_CMD
  243.     }
  244.  
  245.     goto GET_CHAR
  246.  
  247.  
  248. -- Check Online and Error flags
  249. label ERROR_CHECK
  250.     if not Online or not Connected then {
  251.         bye : e = error
  252.         errmsg = 'Lost Connection'
  253.         goto ERR_MSG
  254.     }
  255.     if not error then return
  256.     errmsg = str(errclass) + ', ' + str(errno)
  257.     if errclass = 13 and errno = 12 then errmsg = 'File(s) not found'
  258.     else if errclass = 20 then errmsg = 'Lost Connection'
  259.     else if errclass = 45 then {
  260.         if errno = 1 then errmsg = 'General Timeout'
  261.         else if errno = 2 then errmsg = 'Host not responding'
  262.         else if errno = 3 then errmsg = 'Bad response from host'
  263.         else if errno = 4 then errmsg = 'MaxErrors exceeded'
  264.         else if errno = 5 then errmsg = 'Lost Connection'
  265.         else if errno = 7 or errno = 8 then errmsg = 'Transfer cancelled'
  266.         else if errno = 10 then errmsg = 'File(s) not found'
  267.         else if errno = 11 then errmsg = 'Local disk full'
  268.         else if errno = 12 then errmsg = 'Host disk full'
  269.         else if errno = 15 then errmsg = 'Local system busy'
  270.         else if errno = 18 then errmsg = 'Host BlockSize must be 1,2,3 or 4'
  271.     }
  272. label ERR_MSG
  273.     errmsg = 'Error: ' + errmsg
  274.     print : print errmsg : print
  275.     if Online then {
  276.         reply EOLN;EOLN;errmsg;EOLN;EOLN;
  277.         return
  278.     }
  279.     else goto END_CALL
  280.  
  281.  
  282. -- look for valid commands:
  283. LABEL WHICH_CMD
  284.     -- return of string length is zero
  285.     if length(rs232_str) = 0 then cmd_on = false : return
  286.  
  287.     -- check for Zmodem startup sequence
  288.     if left(rs232_str,2) = 'rz' or left(rs232_str,4) = '**B0' then {
  289.         fname = ''
  290.         Protocol = 'Zmodem'
  291.         goto RECV_FILE
  292.     }
  293.     if not cmd_on then return
  294.     rs232_str = upcase(strip(rs232_str,' ',2))
  295.     fname = slice(rs232_str,2)
  296.  
  297.     if left(rs232_str,3) = 'SEN' then goto SEND_FILE
  298.     if left(rs232_str,2) = 'XM' then {
  299.         Protocol 'CROSSTALK'
  300.         goto SEND_FILE
  301.     }
  302.  
  303.     if left(rs232_str,3) = 'REC' then goto RECV_FILE
  304.     if left(rs232_str,3) = 'REQ' then goto RECV_FILE
  305.     if left(rs232_str,2) = 'RC' then {
  306.         Protocol 'CROSSTALK'
  307.         goto RECV_FILE
  308.     }
  309.  
  310.     if left(rs232_str,3) = 'PRO' then goto SET_PROTOCOL
  311.                     
  312.     if left(rs232_str,3) = 'TYP' then goto TYPE_FILE
  313.  
  314.     if left(rs232_str,3) = 'DIR' then goto DIR_LIST
  315.  
  316.     if left(rs232_str,3) = 'CD ' then goto CHANGE_DIRECTORY
  317.     if left(rs232_str,3) = 'CHD' then goto CHANGE_DIRECTORY
  318.  
  319.     if rs232_str = 'BYE' then goto END_CALL
  320.     if left(rs232_str,3) = 'HEL' then goto HELP_TEXT
  321.  
  322.     -- bad command, spit out help text
  323.     rs232_str = 'help'
  324.  
  325.  
  326. LABEL HELP_TEXT
  327.     hname = left(slice(rs232_str,2),3)
  328.     if null(hname) then {
  329.         reply EOLN;'Crosstalk for Windows Answer mode commands are:';
  330.         reply EOLN;EOLN;
  331.         if left(Permission) = '1' then ...
  332.             reply 'Send <filename>           - tell remote system to send a file';EOLN;
  333.         if mid(Permission,2,1) = '1' then ...
  334.             reply 'Receive <filename>        - tell remote system to receive a file';EOLN;
  335.         if mid(Permission,3,1) = '1' then ...
  336.             reply 'Protocol                  - get remote protocol setting';EOLN; ...
  337.         else if mid(Permission,3,1) = '2' then ...
  338.             reply 'Protocol <protocol_name>  - get/set remote protocol';EOLN;
  339.         if mid(Permission,4,1) = '1' then ...
  340.             reply 'Type <filename>           - get a text file listing';EOLN;
  341.         if mid(Permission,5,1) = '1' then ...
  342.             reply 'Dir <filespec>            - get a directory listing';EOLN;
  343.         if mid(Permission,6,1) = '1' then ...
  344.             reply 'Chdir <dirname>           - change remote drive/directory';EOLN;
  345.         reply 'Bye                       - disconnect';EOLN;
  346.         reply 'Help <command>            - get help';EOLN;EOLN;
  347.         return
  348.     }
  349.     reply EOLN;
  350.     if hname = 'SEN' then {
  351.         if left(Permission) = '0' then return
  352.         reply "Send command: Type 'Send <filename>' at the 'Command:' prompt.  You must";EOLN;
  353.         reply '              specify a filename.';EOLN;EOLN;
  354.         reply '              If you are using Xmodem, Xmodem/CRC, Xmodem/1K, Ymodem/Batch,';EOLN;
  355.         reply "              or Kermit, you must type this Send command at the 'Command:'";EOLN;
  356.         reply '              prompt, and then initiate a Receive command on your local';EOLN;
  357.         reply '              system to begin the transfer.';EOLN;EOLN;
  358.         reply '              If you are using the Zmodem protocol, you must use this Send';EOLN;
  359.         reply '              command to transfer a file from this system to your system.';EOLN;
  360.         reply '              If your local system does not support the auto-start feature';EOLN;
  361.         reply '              of Zmodem, you will also need to type any accompanying Receive';EOLN;
  362.         reply '              command on your system to begin the transfer.';EOLN;
  363.         reply '              If you are using the DART or CROSSTALK protocols, you should';EOLN;
  364.         reply '              not use this command.  To transfer a file from this system';EOLN;
  365.         reply '              to your system, you need only initiate a Request or a Receive';EOLN;
  366.         reply '              command on your local system.  A Send command will then be';EOLN;
  367.         reply '              sent to this system automatically, and the file transfer';EOLN;
  368.         reply '              will begin.';EOLN;
  369.     }
  370.     else if hname = 'REC' then {
  371.         if mid(Permission,2,1) = '0' then return
  372.         reply "Receive command: Type 'Receive [<filename>]' at the 'Command:' prompt.";EOLN;EOLN;
  373.         reply '                 If you are using Xmodem, Xmodem/CRC, Xmodem/1K, Ymodem/Batch,';EOLN;
  374.         reply "                 or Kermit, you must type a Receive command at the 'Command:'";EOLN;
  375.         reply '                 prompt, and then initiate a Send command on your local system';EOLN;
  376.         reply '                 to begin the transfer.  The Xmodem protocols all require that';EOLN;
  377.         reply '                 a filename be specified; Ymodem/Batch and Kermit do not.';EOLN;EOLN;
  378.         reply '                 If you are using the DART, CROSSTALK or Zmodem protocols,';EOLN;
  379.         reply '                 you should not use this command.  To transfer a file from';EOLN;
  380.         reply '                 your system to this system, you need only initiate a Send';EOLN;
  381.         reply '                 command on your local system.  A Receive command will then';EOLN;
  382.         reply '                 be sent to this system automatically, and the file transfer';EOLN;
  383.         reply '                 will begin.';EOLN;
  384.     }
  385.     else if hname = 'PRO' then {
  386.         if mid(Permission,3,1) = '0' then return
  387.         reply "Protocol command: Type 'protocol' at the 'Command:' prompt to see the";EOLN;
  388.         reply "                  remote system's current protocol setting.";EOLN;EOLN;
  389.         if mid(Permission,3,1) = '1' then return
  390.         reply "                  Type 'protocol <protocol_name>' at the 'Command:'";EOLN;
  391.         reply '                  prompt to change the file transfer protocol that';EOLN;
  392.         reply '                  the remote Crosstalk for Windows system is using.';EOLN;
  393.     }
  394.     else if hname = 'TYP' then {
  395.         if mid(Permission,4,1) = '0' then return
  396.         reply "Type command: Type 'type <filename>' at the 'Command:' prompt to get";EOLN;
  397.         reply '              a listing of a text file sent (uploaded) to you.';EOLN;EOLN;
  398.         reply '              If Crosstalk for Windows replies that it cannot find';EOLN;
  399.         reply '              the file, you may need to specify a full pathname.';EOLN;
  400.     }
  401.     else if hname = 'DIR' then {
  402.         if mid(Permission,5,1) = '0' then return
  403.         if DirRestrict then {
  404.             reply "Dir command: Type 'dir' at the 'Command:' prompt to get a";EOLN;
  405.             reply '             directory listing from the remote system.';EOLN;EOLN;
  406.             return
  407.         }
  408.         reply "Dir command: Type 'dir <filespec>' at the 'Command:' prompt to get";EOLN;
  409.         reply "             a directory listing.  If you don't enter a filespec,";EOLN;
  410.         reply '             the remote Crosstalk for Windows system will show you';EOLN;
  411.         reply "             a listing of it's current directory.";EOLN;
  412.     }
  413.     else if hname = 'CD ' or hname = 'CHD' then {
  414.         if mid(Permission,6,1) = '0' then return
  415.         reply "Chdir command: Type 'chdir <dirname>' or 'cd <dirname>' at the 'Command:'";EOLN;
  416.         reply '               prompt to change drives or directories on the remote system.';EOLN;
  417.         reply '               Examples:  "cd \xtalk",  "cd a:\",  "chdir a:\xtalk".';EOLN;
  418.     }
  419.     else if hname = 'BYE' then {
  420.         reply "Bye command: Type 'bye' at the 'Command:' prompt when you are";EOLN;
  421.         reply '             ready to disconnect.';EOLN;
  422.     }
  423.     else rs232_str = 'HEL' : rs232_str = '' : goto HELP_TEXT
  424.     reply EOLN;
  425.     return
  426.  
  427.  
  428. LABEL SEND_FILE
  429.     if left(Permission) = '0' then {
  430.         rs232_str = 'help'
  431.         goto HELP_TEXT
  432.     }
  433.     if Protocol = 'CROSSTALK' then {
  434.         if left(rs232_str,2) <> 'XM' then {
  435.             reply EOLN;INIT_REQU;EOLN;EOLN;
  436.             cmd_on = false
  437.             return
  438.         }
  439.     }
  440.     else if Protocol = 'DART' then {
  441.         if length(fname) then {
  442.             reply EOLN;INIT_REQU;EOLN;EOLN;
  443.             cmd_on = false
  444.             return
  445.         }
  446.     }
  447.     else if Protocol <> 'Zmodem' then {
  448.         if null(fname) then goto NO_FNAME
  449.         if not exists(fname) then {
  450.             errmsg = 'File(s) not found'
  451.             goto ERR_MSG
  452.         }
  453.         reply EOLN;INIT_RECV;EOLN;EOLN;
  454.         wait 3 seconds
  455.     }
  456.     else reply 'rz';EOLN; : wait 5 ticks
  457.     reply EOLN;EOLN;'Processing command ...';EOLN;EOLN;
  458.     savdir = DirFil : send fname
  459.     chdir savdir : DirFil = savdir
  460.     if Protocol = 'CROSSTALK' then reply chr(3);'No more files'
  461.     return
  462.  
  463.  
  464. LABEL RECV_FILE
  465.     if mid(permission,2,1) = '0' then {
  466.         rs232_str = 'help'
  467.         goto HELP_TEXT
  468.     }
  469.     if Protocol = 'CROSSTALK' then {
  470.         if left(rs232_str,2) <> 'RC' then {
  471.             reply EOLN;INIT_SEND;EOLN;EOLN;
  472.             cmd_on = false
  473.             return
  474.         }
  475.     }
  476.     else if Protocol = 'DART' then {
  477.         if length(fname) then {
  478.             reply EOLN;INIT_SEND;EOLN;EOLN;
  479.             cmd_on = false
  480.             return
  481.         }
  482.     }
  483.     else if Protocol <> 'Zmodem' then {
  484.         if left(Protocol,6) = 'Xmodem' and null(fname) then ...
  485.             goto NO_FNAME
  486.             reply EOLN;INIT_SEND;EOLN;EOLN;
  487.         wait 3 seconds
  488.     }
  489.     reply EOLN;EOLN;'Processing command ...';EOLN;EOLN;
  490.     savdir = DirFil : receive fname
  491.     chdir savdir : DirFil = savdir
  492.     return
  493.  
  494.  
  495. LABEL SET_PROTOCOL
  496.     if mid(Permission,3,1) = '0' then {
  497.         rs232_str = 'help'
  498.         goto HELP_TEXT
  499.     }
  500.  
  501.     if mid(Permission,3,1) = '1' then pname = ''
  502.     else pname = slice(rs232_str,2)
  503.     if null(pname) then {
  504.         prot_is = 'Current Protocol is '+Protocol+'.'
  505.         reply EOLN;prot_is;EOLN;EOLN;
  506.         return
  507.     }
  508.  
  509.     p1 = left(pname,2)
  510.     p2 = right(rs232_str,3)
  511.     pok = true
  512.     if p1 = 'DA' then pname = 'DART'
  513.     else if p1 = 'CR' or p1 = 'XT' then pname = 'CROSSTALK'
  514.     else if p1 = 'XM' then {
  515.         if p2 = 'CRC' then pname = 'Xmodem/CRC'
  516.         else if right(p2,2) = '1K' then pname = 'Xmodem/1K'
  517.         else pname = 'Xmodem'
  518.     }
  519.     else if p1 = 'YM' then pname = 'Ymodem/Batch'
  520.     else if p1 = 'ZM' then pname = 'Zmodem'
  521.     else if p1 = 'KE' then pname = 'Kermit'
  522.     else pok = false
  523.     reply EOLN;
  524.     if pok then Protocol pname
  525.     else reply PROTS;EOLN;EOLN;
  526.     return
  527.  
  528.  
  529. LABEL TYPE_FILE
  530.     if mid(Permission,4,1) = '0' then {
  531.         rs232_str = 'help'
  532.         goto HELP_TEXT
  533.     }
  534.     if length(slice(rs232_str,2,".")) > 3 then ...
  535.         rs232_str = left(rs232_str,instr(rs232_str,".",2) + 3)
  536.     fname = slice(rs232_str,2)
  537.     if null(fname) then goto NO_FNAME
  538.     reply EOLN;
  539.     if not exists(fname) then {
  540.         reply "Can't find file ";fname;".";EOLN;EOLN;
  541.         return
  542.     }
  543.     chan = freefile
  544.     open input fname as #chan
  545.     if not chan then return
  546.     row = 1
  547.     while not eof(chan)
  548.         read line #chan, fstr
  549.         reply left(fstr,80);EOLN;
  550.         if row = 22 then {
  551.             reply '... more ... press Enter ...';
  552.             nextline ans, 120
  553.             reply EOLN;
  554.             row = 0
  555.         } else row = row + 1
  556.     wend
  557.     close #chan
  558.     reply EOLN;
  559.     return
  560.  
  561.  
  562. LABEL DIR_LIST
  563.     if mid(Permission,5,1) = '0' then {
  564.         rs232_str = 'help'
  565.         goto HELP_TEXT
  566.     }
  567.     if DirRestrict then fspec = DirFil : fspec2 = DirFil + '\*.*'
  568.     else {
  569.         curpath = curdir
  570.         if not instr(curpath,':') then curpath = curdrive + curpath
  571.  
  572.         fspec = slice(rs232_str,2)
  573.         if null(fspec) or fspec = '*.*' then fspec = curpath
  574.         else if mid(fspec,2,1) <> ':' then ...
  575.             if left(fspec) = '\' then fspec = curdrive + fspec
  576.             else if right(curpath) = '\' then fspec = curpath + fspec
  577.             else fspec = curpath + '\' + fspec
  578.  
  579.         fspec2 = fspec
  580.         if right(fspec) = '\' or right(fspec) = ':' then ...
  581.             fspec2 = fspec + '*.*'
  582.         else if not instr(fspec,'*') then ...
  583.             if fileattr(fspec,10h) & 10h = 10h then ...
  584.                 fspec2 = fspec + '\*.*'
  585.     }
  586.     reply EOLN;'Directory of ';fspec;EOLN;EOLN;
  587.     fname = filefind(fspec2,10h)
  588.     if null(fname) then {
  589.         reply 'File(s) not found.';EOLN;EOLN;
  590.         return
  591.     }
  592.     row = 3
  593.     repeat
  594.         if fileattr & 10h then {
  595.             spcs = 24 - length(fname)
  596.             reply fname;pad('',spcs,' ',1);'<DIR>';EOLN;
  597.         } else reply fname;EOLN;
  598.         if row = 22 then {
  599.             reply ' ... more ... press Enter ...';
  600.             nextline ans, 120
  601.             reply EOLN;
  602.             row = 0
  603.         } else row = row + 1
  604.         fname = filefind
  605.     until null(fname)
  606.     reply EOLN;
  607.     return
  608.  
  609.  
  610. LABEL CHANGE_DIRECTORY
  611.     reply EOLN;
  612.     if mid(Permission,6,1) = '0' then {
  613.         rs232_str = 'help'
  614.         goto HELP_TEXT
  615.     }
  616.     dn = slice(rs232_str,2)
  617.     if null(dn) then {
  618.         reply 'Error: directory name required.';EOLN;EOLN;
  619.         return
  620.     }
  621.  
  622.     curpath = curdir
  623.     if left(curpath) = '\' then curpath = curdrive + curpath
  624.  
  625.     if mid(dn,2,1) <> ':' then ...
  626.         if left(dn) = '\' then dn = curdrive + dn ...
  627.         else if right(curpath) = '\' then dn = curpath + dn ...
  628.         else dn = curpath + '\' + dn ...
  629.     else if length(dn) = 2 then dn = dn + '\'
  630.  
  631.     if not exists(dn,10h) then {
  632.         if right(dn) = '\' then fn = dn + '*.*'
  633.         else fn = dn + '\*.*'
  634.         if not exists(fn) then {
  635.             reply 'Error: invalid drive or directory.';EOLN;EOLN;
  636.             return
  637.         }
  638.     }
  639.  
  640.     if upcase(left(dn,2)) <> curdrive then drive left(dn)
  641.     DirFil = dn : chdir dn
  642.     return
  643.  
  644.  
  645. LABEL NO_FNAME
  646.     reply EOLN;'Error: filename required.';EOLN;EOLN;
  647.     return
  648.  
  649.  
  650. LABEL OPEN_LOG
  651.     if length(Logfile) then {
  652.         f = freefile
  653.         open output Logfile as #f
  654.         write line #f, 'Date of Call   Time of Call   Time Online'
  655.         close #f
  656.     }
  657.     return
  658.  
  659.  
  660. label LOG_CALL
  661.     if length(Logfile) then {
  662.         f = freefile
  663.         open append Logfile as #f
  664.         write line #f, pad(cdate,15)+pad(ctime,15)+hms(ontime,2)
  665.         write line #f, ''
  666.         close #f
  667.     }
  668.     return
  669.  
  670.  
  671. label CHECK_BYE
  672.     alert 'Do you wish to disconnect?', 'Yes', 'No', Cancel
  673.     if choice = 3 then return
  674.     gosub LOG_CALL
  675.     if choice = 2 then end
  676.     goto RESET_MODEM
  677.  
  678.  
  679. LABEL END_CALL
  680.     bye
  681.     wait 1 second
  682.     e = error
  683.     gosub LOG_CALL
  684.     pop
  685.     wait 5 seconds
  686.     return
  687.  
  688.  
  689. LABEL RESET_MODEM
  690. -- Don't do anything if direct-connect
  691.     if Local then goto END_ANSWER
  692.  
  693. -- Is Modem Hayes compatible?
  694.     if right(ModemName, 5) = '2224B' then goto END_ANSWER
  695.     if right(ModemName, 4) = '7407' then goto END_ANSWER
  696.     if right(ModemName, 4) = 'MPDM' then goto END_ANSWER
  697.     if left(ModemName, 6) = 'Bytcom' then goto END_ANSWER
  698.     if left(ModemName, 7) = 'Concord' then goto END_ANSWER
  699.     if ModemName = 'DCA 911' then goto END_ANSWER
  700.     if left(ModemName, 7) = 'IBM Con' then goto END_ANSWER
  701.     if left(ModemName, 3) = 'Nov' then goto END_ANSWER
  702.     if right(ModemName, 4) = '3451' then goto END_ANSWER
  703.     if right(ModemName, 6) = 'VA-212' then goto END_ANSWER
  704.     if ModemName = 'CUSTOM' and not instr(AnswerSetup, 'ATS0') then ...
  705.         goto END_ANSWER
  706.  
  707. -- Tell Hayes compatibles to stop answering calls
  708.     reply 'ATS0=0'
  709.     wait 1 second
  710.  
  711. LABEL END_ANSWER
  712.     bye
  713.     wait 1 second
  714.     e = error
  715.     cls
  716.     end
  717.  
  718.