Chapter
10
1
BASIC
Keywords
ON
PEN
GOSUB
Statement
ON
PEN
GOSUB
line
Transfers program control to a subroutine when you activate the
light pen.
Line
is the first line number in the subroutine to execute when
the light pen
is
activated. If you specify Line
0,
you turn
off
trapping for the pen.
It
is the same
as
executing a PEN
OFF
statement. Use the RETURN statement to exit the subroutine.
BASIC executes the ON PEN GOSUB statement only if a PEN
ON statement has been executed previously to enable light pen
trapping.
If a PEN STOP statement has been issued to halt trapping for
the pen temporarily, BASIC executes the subroutine immediately
after the next PEN ON statement.
When you execute the ON PEN GOSUB statement, BASIC im-
mediately issues
a
PEN STOP statement to prevent recursive
traps. When BASIC executes the RETURN from the subroutine,
it automatically executes another PEN ON statement to enable
pen trapping again, unless the subroutine executes a PEN
OFF
statement.
234