[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
COM_EVENT()
Designates which event at the port triggered a key trap
------------------------------------------------------------------------------
Syntax
COM_EVENT(<nComPort>,<nMode>) --> nCode
Arguments
<nComPort> Designates the port (1 to 4) that is tested for the
event.
<nMode> Designates a numeric value between 1 and 5 (see table 3-2).
Returns
This function returns the code of an incoming character, MSR status, LSR
status, or the number of errors that have occurred to date as a function
of the <nMode> parameter value.
Description
As a rule, it is necessary to determine the cause of a trap if a
character is placed in the keyboard buffer and the procedure specified
with SET KEY TO is called. The numeric parameter determines what
information is accessed. The information returned for modes 1 to 5 are
defined as follows:
Table 3-2: Query Codes for Event Information
------------------------------------------------------------------------
Code Event Information
------------------------------------------------------------------------
1 The function will return the ASCII code of the incoming
character. If no character is available, a -1 is returned.
2 The function returns the status of the MS register at the time
of the interrupt.
3 The function returns the status of the LS register at the time
of the interrupt.
4 The value of the internal error counter will be returned. The
error events in the LSR since the last COM_INIT() will be
counted.
5 Returns the number of characters which had to be rejected
because the buffer was 100% full.
------------------------------------------------------------------------
Notes
. With the exception of the error counter, all status
information is reset when you open the port or when you call
COM_KEY() again.
. The conditions of MSR and LSR are considered at each interrupt
and are linked to the respective status byte in the internal
environment through a logical OR operation. It is therefore possible
to place multiple bits in one of the registers.
. Overrun errors, parity errors, and frame errors (bits 1 to 3)
are counted as errors exclusively.
Important! The input lines on conventional PC interface cards are
normally not terminated. This can lead to inexplicable results when you
query the MSR.
Example
Determine the number of errors that have occurred:
nErrorCnt := COM_EVENT(1, 4)
IF nErrorCnt > 25
* more than 25 errors?
? "Too many errors - terminate program!"
lRelease := .T.
ENDIF
See Also:
COM_KEY()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson