EasyManua.ls Logo

Radio Shack TRS-80 Model 100 - Page 166

Radio Shack TRS-80 Model 100
210 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
FOR
J = 1
TO
2121
Execute the program.
Press the
Cf2)
to interrupt the main program. Again you will see the message:
SUBROUTINE
2
displayed repeatedly
on
the LCD. While this interrupt subroutine
is
executing, press
~.
This time you cannot interrupt the interrupt subroutine. However, after the
subroutine
is
finished, the main program can
be
interrupted with any of the Function
Keys
~,
~
or
~.
The reason for this
is
that the KEY OFF statement in line 200 disabled the Function
Key interrupts. The KEY ON, in line 220, restored the Function Key interrupts at the
completion of the subroutine.
Rather than totally ignore
an
interrupt which occurs during an interrupt subroutine,
you may wish to have it execute at the completion of the current interrupt subroutine.
This can
be
accomplished with the KEY STOP statement.
Change line
200
to:
2121121
KEY
STOP
Execute the program.
Press
Cf2)
to interrupt the main program. Then press
([j)
to interrupt the interrupt
subroutine. Notice that nothing appears to happen. However, if you watch the display
carefully, you will see the message:
SUBROUTINE
1
display after the last SUBROUTINE 2 message
is
displayed.
This is because the KEY STOP statement in line
200 delays execution of the
([j)
interrupt until the current interrupt subroutine is finished.
Experiment
#4:
Checkwriter with Interrupts
In this experiment you will simulate a payroll program which allows interruption from
the keyboard. This could be used to gain
access to a data file while the Computer is
engaged
in
a time consuming process. For example, if a payroll program was printing
a long list of paychecks, it would tie
up
the Computer until the printing was
completed.
Ordinarily,
if
you wanted to gain access to the employee data file, you would have to
wait until the printing finished or else break the program and then resume printing
later. You could use Function Key interrupts, however, to allow immediate inquiry
into the file
without breaking the program. The printing would simply continue after
the inquiry was completed.
Clear memory with the NEW command and then enter the following program:
1121
CLS:
KEY
ON
: ER$=STRING$13!21,"
")
2121
ON
KEY
GOSUB
14121
3121
FOR
1=1
TO
G:READ
N$II)
,RII)
,HII):NEXTI
4121
FOR
1=1
TO
G
5121
LINE
112,!21)-122G,47),1,BF
160

Other manuals for Radio Shack TRS-80 Model 100

Related product manuals