ChaDter
10
I
BASIC
Kevwords
ON
COM(
)
GOSUB
Statement
ON
COM(channeZ)
GOSUB
line
Transfers program control to a subroutine beginning at
line
when activity occurs on the communication channel.
Channel
selects communications Channel
1
or
2.
Line
is the
first
line
of
the subroutine
to
be executed when activ-
ity occurs on the specified communications channel. If you spec-
ify Line
0,
you turn
off
communications trapping. Use the
RETURN statement
to
exit the subroutine.
BASIC executes the ON
COM(
)
GOSUB statement only if a
COM( ON statement has been previously executed
to
enable
communication trapping. If a COM(
)
STOP statement has been
issued to halt communication trapping temporarily, BASIC exe-
cutes the subroutine immediately after the next
COM(
1
ON
statement.
When you execute the
ON
COM(
)
GOSUB statement, BASIC
immediately issues
a
COM(
1
STOP statement to prevent recur-
sive traps. When BASIC executes the RETURN from the subrou-
tine, it automatically executes another COM(
)
ON statement
to
enable communication trapping again, unless the subroutine exe-
cutes
a
COM(
OFF
statement.
226