Radio Shack TRS-80 Model 100 Basic Manual page 163

Basic language lab
Hide thumbs Also See for TRS-80 Model 100:
Table of Contents

Advertisement

Use the KEYLIST command to confirm that you have restored
~
to its original
form. You can restore (fg) and
@ to their original null string if you wish by entering
KEY 8,
1111
KEY
7,
1111
You can reprogram any function key with any string up to 15 characters. Just
remember to use CHR$(l3) for (ENTER) and CHR$(34) for the quotation mark.
Experiment #2 Interrupting Execution
You can also use the function keys to control execution of a program. The ON KEY
GOSUB statement lets you immediately interrupt a program by pressing a function
key. Depending upon the Function Key that is pressed, the program will jump to one
of several subroutines.
This interrupt capability alluws direct keybuard cuntrol uf a program during executiun.
The action is similar to pressing (BREAK), except that execution is not terminated, only
redirected.
The program below illustrates how Function Key interrupts work. Clear memory with
the NEW command and enter the following program:
10 KEY ON
20 ON KEY GOSU6 100,200,300
30 PRINT I : 1=1+1 : GOTO 30
100 PRINT "SU6ROUTINE 1"
RETURN
200 PRINT "SU6ROUTINE 2"
RETURN
300 PRINT "SU6ROUTINE 3"
RETURN
Execute this program and watch the display.
You should see a series of numbers, starting from zero and increasing by one,
scrolling on the display.
Press CfI). You should see the message:
SU6ROUTINE 1
displayed and then the numbers will continue scrolling. Press
(E2) to display the
message:
SU6ROUTINE 2
or press
CEID
to display the message:
SU6ROUTINE 3
You can interrupt the printing of numbers at any time using any of the first three
Function Keys. Execution jumps to the appropriate subroutine depending upon which
Function Key is pressed.
Use (BREAK) to terminate execution of the program.
Line
18
The KEY ON statement enables the Function Key interrupt capability. In
effect, it tells the computer to keep looking for a function key to be pressed. This
statement is used in conjunction with the ON KEY GOSUB.
157

Advertisement

Table of Contents
loading

Table of Contents