Chapter
10
I
BASIC
Ke.ywords
COM
Statement
COM(channe1)
action
Turns on, turns off,
or
temporarily halts the trapping of activity
on the specified communications channel.
Channel
selects communications channel
1
or
2.
Action
may be any of the following:
ON
enables communications trapping.
OFF
disables communications trapping.
STOP temporarily suspends communications trapping.
Use the COM statement in
a
communications trap routine with
the
ON
COM() GOSUB statement
to
detect when characters
have come into the communications channel.
The COM(
)
ON
statement turns on the trap. BASIC checks after
every program statement
to
see if
a
character has come into the
communications channel. If
so,
BASIC transfers program control
to
the line number specified in the
ON
COM() GOSUB
statement
.
The COM(
)
STOP statement temporarily halts communications
trapping. If activity occurs on the communications channel,
BASIC does not transfer program control
to
the
ON
COM(
1
GO-
SUB statement until you turn on communications trapping
again by executing a COM()
ON
statement. BASIC remembers
that activity took place and branches
to
the subroutine immedi-
ately after communications trapping is turned on again.
The COM(
)
OFF
statement turns off communications activity
trapping. BASIC does not remember
if
activity took place when
communications trapping is turned on again.
We recommend that your trap routine read the entire message
from the communications port.
Do
not use a COM trap
to
trap a
single character message because the amount of time required
to
trap and read every character can cause the communications
buffer
to
overflow.
124