Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Clipper Tools One Guide - <b>com_key()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
COM_KEY()

Syntax:     COM_KEY(<port>[,<char>][,<expN1>])

Arguments:  <port> Denotes the interface where certain activities are being
            monitored, COM1: (1) or COM2: (2).
            [<char>] Denotes the key code that will be placed in the
            keyboard buffer.  If the interface generates an interrupt, all
            the values allowed in the Clipper command KEYBOARD are
            valid.  If <char> is not supplied, then the monitoring function of
            COM_KEY() will be switched off.
            [<expN1>] Stipulates another key code, which is placed in the
            keyboard buffer when the reception buffer of the interface is
            75 percent or more full.

Returns:    A logical value.
            (.T.) when the traps have been switched on.  (.F.) when this
            mode has been switched off.

Usage:      With this function it is possible to monitor the interfaces while
            the program is in a READ, for instance.  Various events on
            the interface may then lead to a specifically chosen key code
            to be placed in the keyboard buffer.  This will occur when:

            a) the data arrives at the interface
            b) a transmission error or a BREAK is recognized in the LSR
            c) one of the signals in the MSR changes
            d) the reception buffer is 75 percent or more full

            The condition of MSR, LSR, the number of errors that have occurred
            to date and the character which released the trap, will be stored
            in an internal environment.  The COM_EVENT() function may
            be used to recall this information.  This procedure will be
            necessary,as the register of flags which have triggered the
            interrupt will be automatically reset, and all information would
            otherwise have been lost.  If the argument 2 has been
            indicated, it is possible to establish yet another procedure via
            SET KEY, which will be activated when the reception buffer is
            75 percent or more full.  However, if this second argument is
            used, then the key code <char> will not be placed in the
            keyboard buffer if the buffer is 75 percent or more full.

            It will on the other hand be possible to continue to monitor
            the MSR and LSR.

Note:       COM_KEY() must be reactivated after each executed trap,
            whereby the information of the internal environment will be
            erased.  Placing a symbol when the buffer is full will be
            independent of COM_SOFT() or COM_HARD().

Library:    CT1.LIB


--------------------------------- Example ------------------------------

Examples:   * CHR(227) is placed in  the keyboard buffer
            * and will call the com_errors procedure if
            * an error is recognized on port 2 or there
            * is a change in the modem status signals.
            * CHR(228) will be placed in the keyboard
            * buffer as soon as the buffer is 75
            * percent or more full and the buffer_full
            * procedure called up in this manner.

            COM_OPEN(2,1000)                    && COM2: open
            COM_INIT(2,1200,"N",8,1)            && COM2: initialized

            SET KEY 227 to com_errors
            SET KEY 228 to buffer_full

            COM_KEY(227,228)                    && COM2: monitored
            ...

            name = SPACE(20)                    && The interface may
                                                && trigger the
                                                && call up of
            @ 10,10 GET name                    && com_trap during
                                                && a GET...READ

            READ
            COM_KEY(2)                          && Switch off
                                                && monitor
            RETURN


            PROCEDURE com_errors
            PARAMETERS a,b,c

            status = COM_EVENT(2,2)             && Read  condition of
                                                && the MSR.
            IF ISBIT(status,6)                  && Bit 6 set
               ? "(Ring)  Detected."
            ELSE
               status = COM_EVENT(2,3)          && Read  condition of
                                                && the LSR.
               IF ISBIT(status,4)               && Bit 4 set
                  ? "BREAK  Detected."

               ENDIF

            ENDIF


            COM_KEY(2,227,228)                  && Reactivate traps.

            RETURN


            PROCEDURE buffer_full
            PARAMETERS a,b,c

            * The input buffer must be read.
            SELECT MessDat

            REPLACE ComDat WITH COM_READ(2)     && Read
                                                && everything.

            SKIP
            SELECT input

            COM_KEY(2,227,228)                  && Reactivate
                                                && traps.
            RETURN



See Also: COM_COUNT() COM_EVENT() COM_LSR() COM_MSR() LASTKFUNC() LASTKLINE() LASTKPROC()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson