QBasic 1.1: COM Statement
Explanation
COM, ON COM Statements
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.
Worth knowing
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
Syntax
COM(n%) ON |
COM(n%) OFF |
COM(n%) STOP |
ON COM(n%) GOSUB line |
Description / Parameter(s)
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