home *** CD-ROM | disk | FTP | other *** search
- *
- * Program Name: AUTOCOMM.PRG Client: Developers Conference
- * Date Created: 05/16/90 Language: Clipper 5.0
- * Time Created: 06:21 pm Author: Jim Tamburrino
- * Compile line: CLIPPER autocomm -m
- * Link command: RTLINK FI autocomm PLL clipper LIB swasync, extend
- *
- * Copyright 1990, LMT Computer Service, Inc., All Rights Reserved
- *.............................................................................
-
- #define pPORT 0
- #define pBAUD 2400
- #define pPARITY 0
- #define pSTOP 1
- #define pWORDLEN 0
- #define p1SEC 18
-
-
- IF OpenComm(pPORT, 2000, 2000) <> 0
- ? "Could not open COM port"
- QUIT
- END
-
- SetBaud(pPORT, pBAUD, pPARITY, pSTOP, pWORDLEN)
- ControlRTS(pPORT, 1)
-
- SmDial(pPORT,"1-404-998-2804") && Replace with the number to call
-
- CLS
- ?"Auto script processing system"
- ?
-
- DBWaitFor(pPORT, "adbus.dbf")
-
- CloseComm(pPORT)
-
- USE adbus NEW
- Resetexe()
- AllActive(.T.)
-
- CLS
-
-
- ****************************************************************************
- *
- * Function Name: DBWAITFOR()
- *
- * Comment: Example auto logon program.
- *
- * Modification Log:
- *
- * Rev. Date By Description
- * --------------------------------------------------------------
- * 1.00 11/13/89 John Halovanic Initial Creation
- * 2.00 05/15/90 Jim Tamburrino Rewritten for Clipper 5.0
- *
- *
- *
- * --------------------------------------------------------------
- *
- *
- *
- * Description:
- *
- * This function is to be called after connection to a system and
- * waiting to answer prompts. DBWAITFOR() uses a .dbf file to hold
- * the search and respond information for script processing. You can
- * set the string to look for (WAITSTRING) and the response when the
- * string is found (SENDSTRING). You have the option to sen CR and LF
- * if needed. Also you can have active and inactive records in your
- * .dbf. The (SCRIPTMAC) field is for a command to be executed when the
- * the string is found. (ie. TXXMODEM(wfport,"file.exe"))
- *
- * The DBWAITFOR() function will work with ANSI or TTY terminal emulation
- * but if you are useing ANSI you must have ANSI.SYS loaded in your
- * CONFIG.SYS. (ie. DEVICE=ANSI.SYS)
- *
- *
- * Structure for database: script.dbf
- * Number of data records: 5
- * Field Field Name Type Width
- * 1 WAITSTRING Character 60 String to wait for
- * 2 SENDSTRING Character 60 String to respond with
- * 3 CR Logical 1 TRUE Send CR, FALSE dont' send
- * 4 LF Logical 1 TRUE Send LF, FALSE dont' send
- * 5 ACTIVE Logical 1 Is record active in search
- * 6 SCRIPTMAC Character 80 Macro command to be executed
- * 7 EXENUMTIME Numeric 3 Max # of times to execute
- * 8 EXENUMLEFT Numeric 3 Max # excute decrement var.
- * * Total ** 210
- *
- ******************************************************************************
- *
- *
- PROCEDURE DBWaitFor(wfport, scriptfile)
-
- LOCAL rn := 0, key := 0, buildstr := "", recstr := ""
- M->maxlength := 149; M->term := 13
-
- * Optional external functions to execute via macro's
- EXTERNAL txxmodem, rxxmodem, rxascii, txascii
-
- M->outfile := FOPEN("CON",1) && open file console (standard I/O)
- USE (scriptfile) NEW ALIAS Script
- SET FILTER TO active && optional active field in .dbf
-
- WHILE key <> 27 && Escape to terminate
-
- IF !RXEmpty(wfport)
- recstr := RXBuf(wfport, M->maxlength, M->term)
- rn := RXStringEr()
- buildstr := buildstr + recstr
- FWRITE(M->outfile, recstr)
-
- DO CASE
-
- CASE rn = -76
- SrchTable(wfport, buildstr)
- buildstr := ""
-
- CASE rn = -71
- IF SrchTable(wfport, buildstr)
- buildstr := ""
- END
-
- ENDCASE
-
- END
-
- IF key > 0
- TXChar(wfport, CHR(key))
- END
-
- key := INKEY()
-
- ENDDO
-
- CLOSE DATABASES
- FCLOSE(M->outfile)
-
-
- **************************
- FUNCTION SrchTable(wfport, string)
-
- LOCAL rval := .F., rn := 0
- M->mscriptmac := ""
- GO TOP
- WHILE !EOF()
- IF UPPER(TRIM(Script->waitstring)) $ UPPER(string)
- TXString(wfport, TRIM(Script->sendstring))
- IF Script->cr
- TXChar(wfport, CHR(13))
- END
- IF Script->lf
- TXChar(wfport, CHR(10))
- END
-
- Script->exenumleft := Script->exenumleft - 1
-
- IF !EMPTY(Script->scriptmac)
- SWDelay(p1SEC)
- FWRITE(M->outfile, RXBuf(wfport, M->maxlength, M->term))
- M->mscriptmac := TRIM(Script->scriptmac)
- rn := &mscriptmac.
- END
-
- Script->active := !(Script->exenumleft == 0)
- rval := .T.
-
- EXIT
- ENDIF
- SKIP
- ENDDO
-
- RETURN rval
-
- ************************
- PROCEDURE AllActive(seton)
-
- DBEVAL({|| FIELD->active := seton})
-
-
- ************************
- PROCEDURE Resetexe
-
- DBEVAL({|| FIELD->exenumleft := FIELD->exenumtime})
-
-
- ************************************************
- *
- * The following functions are callable from the
- * scriptmac field in the data base.
- *
- ************************
- FUNCTION STOP
-
- KEYBOARD CHR(27)
-
- RETURN 0
-
- ************************
- PROCEDURE OneActive(seton)
-
- FIELD->active := seton
-
-
- ************************
- FUNCTION Reset1exe
-
- FIELD->exenumleft := FIELD->exenumtime
-
- RETURN FIELD->exenumtime
-
-
- ************************
- PROCEDURE ReplRsp(swrc)
-
- FIELD->sendstring := swrc
-
-
- *eof() autocomm.prg