qbasic.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
COM, ON COM Statements
  Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
COM enables, disables, or suspends event trapping on a communications port.
If event trapping is enabled, ON COM branches to a subroutine whenever
characters are received at the port.
 
COM(n%) ON
COM(n%) OFF
COM(n%) STOP
ON COM(n%) GOSUB line
 
    ■ n%              The number of a COM (serial) port (1 or 2).
    ■ COM(n%) ON      Enables trapping of a communications event.
    ■ COM(n%) OFF     Disables communications event trapping.
    ■ COM(n%) STOP    Suspends communications event trapping. Events are
                      processed once event trapping is enabled by COM ON.
    ■ line            The label or number of the first line of the
                      event-trapping subroutine.
 
Example:
    COM(1) ON       'Enable event trapping on port 1.
    ON COM(1) GOSUB ComHandler
    DO : LOOP WHILE INKEY$ = ""
    COM(1) OFF
    END
 
    ComHandler:
        PRINT "Something was typed at the terminal attached to COM1."
        RETURN
 
See Also    OPEN COM