home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / TAMBURRI.ZIP / AUTOCOMM.PRG < prev    next >
Encoding:
Text File  |  1990-05-20  |  5.7 KB  |  222 lines

  1. *
  2. *   Program Name: AUTOCOMM.PRG         Client: Developers Conference
  3. *   Date Created: 05/16/90           Language: Clipper 5.0                                            
  4. *   Time Created: 06:21 pm             Author: Jim Tamburrino                            
  5. *   Compile line: CLIPPER autocomm -m
  6. *   Link command: RTLINK FI autocomm PLL clipper LIB swasync, extend
  7. *
  8. * Copyright 1990, LMT Computer Service, Inc., All Rights Reserved
  9. *............................................................................. 
  10.  
  11. #define pPORT     0
  12. #define pBAUD     2400
  13. #define pPARITY   0
  14. #define pSTOP     1
  15. #define pWORDLEN  0      
  16. #define p1SEC     18
  17.  
  18.  
  19. IF OpenComm(pPORT, 2000, 2000) <> 0
  20.    ? "Could not open COM port"
  21.    QUIT
  22. END
  23.  
  24. SetBaud(pPORT, pBAUD, pPARITY, pSTOP, pWORDLEN)
  25. ControlRTS(pPORT, 1)
  26.  
  27. SmDial(pPORT,"1-404-998-2804")        && Replace with the number to call
  28.  
  29. CLS
  30. ?"Auto script processing system"
  31. ?
  32.  
  33. DBWaitFor(pPORT, "adbus.dbf")
  34.  
  35. CloseComm(pPORT)
  36.  
  37. USE adbus NEW
  38. Resetexe()
  39. AllActive(.T.)
  40.  
  41. CLS
  42.  
  43.  
  44. ****************************************************************************
  45. *
  46. *    Function Name:    DBWAITFOR()
  47. *
  48. *    Comment: Example auto logon program.
  49. *
  50. *    Modification Log:
  51. *
  52. *    Rev.    Date      By                     Description
  53. *    --------------------------------------------------------------
  54. *    1.00    11/13/89  John Halovanic         Initial Creation
  55. *  2.00    05/15/90  Jim Tamburrino         Rewritten for Clipper 5.0
  56. *
  57. *
  58. *
  59. *    --------------------------------------------------------------
  60. *
  61. *
  62. *
  63. *    Description:
  64. *
  65. *    This function is to be called after connection to a system and
  66. *    waiting to answer prompts.  DBWAITFOR() uses a .dbf file to hold
  67. *    the search and respond information for script processing.  You can
  68. *    set the string to look for (WAITSTRING) and the response when the
  69. *    string is found (SENDSTRING).  You have the option to sen CR and LF
  70. *    if needed.  Also you can have active and inactive records in your
  71. *    .dbf. The (SCRIPTMAC) field is for a command to be executed when the
  72. *    the string is found. (ie. TXXMODEM(wfport,"file.exe"))
  73. *
  74. *    The DBWAITFOR() function will work with ANSI or TTY terminal emulation
  75. *    but if you are useing ANSI you must have ANSI.SYS loaded in your 
  76. *    CONFIG.SYS.  (ie. DEVICE=ANSI.SYS)
  77. *
  78. *
  79. *    Structure for database: script.dbf
  80. *    Number of data records:       5
  81. *    Field  Field Name  Type       Width
  82. *        1  WAITSTRING  Character     60        String to wait for    
  83. *        2  SENDSTRING  Character     60     String to respond with
  84. *        3  CR          Logical        1     TRUE Send CR, FALSE dont' send
  85. *        4  LF          Logical        1     TRUE Send LF, FALSE dont' send
  86. *        5  ACTIVE      Logical        1     Is record active in search
  87. *        6  SCRIPTMAC   Character     80     Macro command to be executed
  88. *        7  EXENUMTIME  Numeric        3     Max # of times to execute    
  89. *        8  EXENUMLEFT  Numeric        3     Max # excute decrement var.
  90. *     * Total **                     210
  91. *
  92. ******************************************************************************
  93. *
  94. *
  95. PROCEDURE DBWaitFor(wfport, scriptfile)
  96.  
  97.    LOCAL rn := 0, key := 0, buildstr := "", recstr := ""
  98.    M->maxlength := 149; M->term := 13
  99.  
  100.    * Optional external functions to execute via macro's
  101.    EXTERNAL txxmodem, rxxmodem, rxascii, txascii
  102.  
  103.    M->outfile := FOPEN("CON",1)         && open file console (standard I/O)
  104.    USE (scriptfile) NEW ALIAS Script     
  105.    SET FILTER TO active                      && optional active field in .dbf
  106.  
  107.    WHILE key <> 27                      && Escape to terminate
  108.  
  109.       IF !RXEmpty(wfport)
  110.          recstr   := RXBuf(wfport, M->maxlength, M->term)
  111.          rn       := RXStringEr()
  112.          buildstr := buildstr + recstr
  113.          FWRITE(M->outfile, recstr)
  114.  
  115.          DO CASE
  116.  
  117.          CASE rn = -76
  118.              SrchTable(wfport, buildstr)
  119.             buildstr := ""             
  120.  
  121.           CASE rn = -71
  122.              IF SrchTable(wfport, buildstr)
  123.                    buildstr := ""
  124.             END
  125.  
  126.          ENDCASE
  127.  
  128.       END
  129.  
  130.       IF key > 0 
  131.          TXChar(wfport, CHR(key))
  132.       END     
  133.  
  134.       key := INKEY()
  135.  
  136.    ENDDO
  137.  
  138.    CLOSE DATABASES
  139.    FCLOSE(M->outfile)
  140.  
  141.  
  142. **************************
  143. FUNCTION SrchTable(wfport, string)
  144.  
  145.    LOCAL rval := .F., rn := 0
  146.    M->mscriptmac := ""
  147.    GO TOP
  148.    WHILE !EOF()
  149.       IF UPPER(TRIM(Script->waitstring)) $ UPPER(string)
  150.          TXString(wfport, TRIM(Script->sendstring))
  151.          IF Script->cr
  152.             TXChar(wfport, CHR(13))
  153.          END
  154.          IF Script->lf
  155.             TXChar(wfport, CHR(10))
  156.          END
  157.  
  158.          Script->exenumleft := Script->exenumleft - 1
  159.  
  160.          IF !EMPTY(Script->scriptmac)
  161.             SWDelay(p1SEC)
  162.             FWRITE(M->outfile, RXBuf(wfport, M->maxlength, M->term))
  163.             M->mscriptmac := TRIM(Script->scriptmac)
  164.             rn := &mscriptmac.
  165.          END
  166.  
  167.          Script->active := !(Script->exenumleft == 0)
  168.          rval := .T.
  169.  
  170.          EXIT
  171.       ENDIF
  172.       SKIP
  173.    ENDDO
  174.  
  175. RETURN rval                 
  176.  
  177. ************************
  178. PROCEDURE AllActive(seton)
  179.  
  180.    DBEVAL({|| FIELD->active := seton})
  181.  
  182.  
  183. ************************
  184. PROCEDURE Resetexe
  185.  
  186.    DBEVAL({|| FIELD->exenumleft := FIELD->exenumtime})
  187.  
  188.  
  189. ************************************************
  190. *
  191. *  The following functions are callable from the
  192. *  scriptmac field in the data base.
  193. *
  194. ************************
  195. FUNCTION STOP
  196.  
  197.    KEYBOARD CHR(27)
  198.  
  199. RETURN 0
  200.  
  201. ************************
  202. PROCEDURE OneActive(seton)
  203.  
  204.    FIELD->active := seton
  205.  
  206.  
  207. ************************
  208. FUNCTION Reset1exe
  209.  
  210.    FIELD->exenumleft := FIELD->exenumtime
  211.  
  212. RETURN FIELD->exenumtime
  213.  
  214.  
  215. ************************
  216. PROCEDURE ReplRsp(swrc)
  217.  
  218.    FIELD->sendstring := swrc
  219.  
  220.  
  221. *eof() autocomm.prg
  222.