Radio Shack TRS-80 Model 100 Basic Manual page 60

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

Advertisement

Experiment #7 How to Escape From an Infinite
Loop
It is easy to add some statements so that programs that contain infinite loops will
terminate upon request.
In the Sales Commission program, for example, the sales total will never be negative.
But you can modify the program so that it terminates whenever a negative value for
sales is entered.
Type the new line:
15 IF ST
<
0 THEN STOP
(ENTER)
The STOP statement, terminates execution and has the same effect as pressing
~.
The program will terminate if ST is negative, but continue if it is not.
Run the program.
When prompted to do so, enter a dummy name (such as END) and a negative sales
amount (such as -1). Note that the program terminates immediately without
computing any commission.
The dummy name was necessary because the INPUT statement in Line 10 requires
you to enter two input quantities. Since a negative sales amount terminates execution,
the name you enter will not be used.
You can have more than one STOP statement in your program. Of course your
program need not have any STOP statements in it at all.
Experiment #8 Individual Commissions for the
Salesmen
The Sales Commission program calculates every salesman's commission using the
same rate. Now we will modify the program so that each salesman has his own
commission rate. Here is a list of salesmen and their commission rates:
Name
ADAMS
JONES
LEE
SMITH
VINSON
Rate
15%
16%
18%
20%
14%
When any of the above names is entered, the program must look in the table to find
the corresponding rate before the commission can be calculated. Make the following
changes to the program:
Retype line 20 as follows
20 READ NU
t
CR
S4

Advertisement

Table of Contents
loading

Table of Contents