USING dBASE III WITH WORDTECH'S COMPILER TO DETECT THE LOSS OF A CARRIER SIGNAL
-------------------------------------------------------------------------------

     The following is an example of using the WordTech dBIII Compiler to detect
the loss of a carrier signal.  This technique was developed to allow a compiled
dBASE III program which was executed by a remote terminal from a custom written
bullentin board-type program running under MultiLink Advanced to detect the loss
of the carrier signal.  This routine is called after each two or three lines of
output through the modem to prevent the 255 byte communications buffer from
becoming filled when the carrier is lost and immobilizing the memory partition
in which it is running.

     The program uses a new command (DOSINT) and a new function (BITSET)
provided by the WordTech compiler to access DOS interrupts and read the status
of specified bits in values returned from the interrupt call.  The interrupt
in this program is 7F hex which is a program generated interrupt created by
MultiLink Advanced.  The DOS interrupt 14 hex can be used in an identical manner
to detect the loss of carrier.  However it may not be possible to control the
DTR line in exactly the same way this routine does by using the 800 hex and 803
hex function calls to the 14 hex interrupt.

     I realize that this routine has a limited audience.  You have to be running
a WordTech compiled dBASE III program from a communications program in a memory
partition created by MultiLink Advanced for the routine to be of interest.  But
I hope someone will find it useful or at least of interest.

                                                             Cal Thames

********************************************************************************
* DBASE III CARRIER DETECT ROUTINE

* PLEASE NOTE THAT THIS ROUTINE MUST BE COMPILED USING THE WORDTECH COMPILER AND
* WILL NOT EXECUTE USING THE dBASE INTERPRETER

* INITIALIZES THE AX, BX, CX, AND DX REGISTERS.

STORE 0 TO bxreg,cxreg
STORE 1 TO dxreg
STORE 768 TO axreg

* DOSINT IS THE WORDTECH COMPILER COMMAND WHICH ALLOWS ACCESS TO THE DOS
* INTERRUPT SPECIFIED IN DECIMAL. VALUES CAN BE PASSED TO AND FROM THE
* INTERRUPT THROUGH THE ARGUMENTS FOLLOWING THE COMMAND. THE VALUE OF 127
* DECIMAL (7F HEX) IS THE INTERRUPT ESTABLISHED BY MULTILINK ADVANCED TO ALLOW
* ACCESS TO VARIOUS DOS ACTIVITIES. THE NORMAL DOS INTERRUPT OF 20 DECIMAL (OR
* 14 HEX) COULD ALSO BE USED SINCE THE FUNCTION CALL PLACED IN AX ABOVE SEEMS
* TO BE IDENTICAL FOR BOTH INTERRUPTS.
* THE VALUE IN AX OF 768 DECIMAL (0300 HEX) IS THE FUNCTION CALL TO RETURN THE
* STATUS OF THE COMMUNICATIONS PORT IDENTIFIED IN DX.
* A VALUE OF 1 IN DX SPECIFIES COM2. 0 IN DX WOULD SPECIFY COM1.

DOSINT 127,axreg,bxreg,cxreg,dxreg

* BITSET() IS A WORDTECH COMPILER FUNCTION WHICH RETURNS A LOGICAL RESPONSE
* (TRUE OR FALSE) BASED ON WHETHER THE SPECIFIED BIT IN THE FUNCTION'S ARGUMENT
* IS ON OR OFF. AS A RESULT OF CALLING INTERRUPT 127 DECIMAL WITH FUNCTION 768
* DECIMAL, THE VALUE RETURNED IN AX IS THE COMMO (COM2) PORT STATUS. THE EIGHT
* BITS IN THE AH PORTION OF AX CONTAIN INFORMATION ON THE LINE CONTROL STATUS AS
* FOLLOWS:
*
*          BIT 7 = TIME OUT
*          BIT 6 = TRANSMIT SHIFT REGISTER EMPTY
*          BIT 5 = TRANSMIT HOLDING REGISTER EMPTY
*          BIT 4 = BREAK DETECT
*          BIT 3 = FRAMING ERROR
*          BIT 2 = PARITY ERROR
*          BIT 1 = OVERRUN ERROR
*          BIT 0 = DATA READY
*
* THE EIGHT BITS IN THE AL PORTION OF AX CONTAIN INFORMATION ON THE MODEM
* STATUS AS FOLLOWS:
*
*          BIT 7 = RECEIVE LINE SIGNAL DETECT (CARRIER DETECT)
*          BIT 6 = RING INDICATOR
*          BIT 5 = DATA SET READY
*          BIT 4 = CLEAR TO SEND
*          BIT 3 = DELTA RECEIVE LINE SIGNAL DETECT
*          BIT 2 = TRAILING EDGE RING DETECTOR
*          BIT 1 = DELTA DATA SET READY
*          BIT 0 = DELTA CLEAR TO SEND
*
* THE BIT OF INTEREST IS BIT 7 IN AL. IF THIS BIT IS ON (TRUE), A CARRIER
* SIGNAL WAS DETECTED. IF THE CARRIER IS LOST, THIS BIT WILL BE OFF (FALSE).

IF .NOT. BITSET(axreg,7)

* IF BIT 7 IS NOT SET, BITSET() RETURNS FALSE.
* REMAINDER OF ROUTINE PROPERLY RESETS MODEM AND EXITS PROGRAM
* ASSIGN NEW VALUES TO THE REGISTERS

   STORE 0 TO bxreg,cxreg
   STORE 1 TO dxreg
   STORE 2048 TO axreg

* THE VALUE 2048 DECIMAL (800 HEX) IS THE FUNCTION FOR INTERRUPT 127 DECIMAL TO
* WRITE THE VALUE IN AL TO THE MODEM CONTROL REGISTER. AL IS 00 HEX WHICH HANGS
* UP THE MODEM BY TURNING OFF THE DATA TERMINAL READY (DTR) LINE.

   DOSINT 127,axreg,bxreg,cxreg,dxreg

* CREATES A BRIEF PAUSE BEFORE ISSUING ANOTHER COMMAND TO THE MODEM.

   increment = 0
   DO WHILE increment < 50
      increment = increment + 1
   ENDDO

* ASSIGN NEW VALUES TO THE REGISTERS

   STORE 0 TO bxreg,cxreg
   STORE 1 TO dxreg
   STORE 2051 TO axreg

* THE VALUE 2051 DECIMAL (803 HEX) IS TURNS ON THE DTR LINE.

   DOSINT 127,axreg,bxreg,cxreg,dxreg

* CLOSE DATABASE AND INDEX FILES AND EXIT PROGRAM

   CLOSE DATABASES
   RETURN
ENDIF
