Tandy 1000 Basic Reference Manual page 195

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I BASIC Keywords
0
You can trap any key, including
(CTRL]
@ J , [CTRLIIBREAK),
and [CTRL]
[DELETE) (the soft boot). This feature makes
it possible to prevent BASIC application users from con-
trol-breaking out of a program or from accidentally reset-
ting the computer.
You can use the KEYITrap statement in a key trapping routine
with the
ON
KEYO GOSUB statement
to
detect when a specific
key is pressed.
The KEYO
ON
statement turns on key trapping for a specific
key. BASIC checks after each program statement to see if the
specified key has been pressed. If so, BASIC transfers program
control to the line number specified in the ON KEY() GOSUB
statement. For example:
K E Y ( 3 )
ON
ON K E Y ( 3 )
GOSUB 1 0 0 0
BASIC
turns
on a trap for
m.
BASIC continues t o execute the
other program statements, checking after each statement t o see
if
iF3]
has been pressed. When IF3] is pressed, BASIC branches to
the subroutine beginning at Line 1000.
KEYO STOP temporarily halts trapping for the specified key. If
the specified key is pressed, BASIC does not transfer program
control to the
ON
KEYO GOSUB until you turn on key trapping
again with a KEY()
ON
statement. BASIC remembers that the
key was pressed and branches t o the subroutine immediately
after key trapping is turned on again.
KEY() OFF turns off key trapping. BASIC does not remember
that the key has been pressed when key trapping is turned on
again.
Note: Key trapping only occurs while BASIC is run-
ning a program.
See ON KEY() GOSUB for more information on key trapping.
Sample Program
See ON KEY() GOSUB.
193

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents