Radio Shack TRS-80 Model 100 Basic Manual page 126

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

Advertisement

Line 398
The statement
PRINT@ A," ";
erases the old asterisk by printing a space over it. The second statement
PRINT@ AT,
"4";
prints the asterisk at the new position. The semicolons at the end of these PRINT@
statements are required to prevent scrolling when printing in the bottom row.
Line 318
The variable A stores the "old" asterisk position, and AT stores the "new"
asterisk position. This assignment statement updates the "old" asterisk position.
Execution is returned to Line 200 to allow repeated movement of the asterisk.
Experiment #9 Move in Four Directions
Execute the previous program and hold down
CU.
The asterisk should move
continuously to the left. When the asterisk reaches the left margin, it jumps over to
the right and up one line. Continue to hold down
rn
until the asterisk reaches the
upper left corner of the display. If you try to move past the upper left corner, the
program will terminate execution with an error message
?FC Error in 300
This "Function Call" error occurs because the PRINT@ position goes negative if
rn
is pressed with the asterisk in the upper left corner (PRINT@ position 0).
The program can be modified to prevent this error from occurring. At the same time,
it is relatively easy to allow the asterisk to be moved vertically. Enter the following
changes into the program:
230 IF A$="E" THEN AT=AT-£10
2£10 IF A$="X" THEN AT=AT+£10
250 IF AT)=0 AND AT(=318 GOTO 300
260 PRINT CHR$(7l; : AT=A : GOTO 200
List the program to confirm that it is now:
100 CLS : A = 100 : AT = A : PRINT @ A,
"*"
200 A$ = INKEY$ : IF A$
= ""
THEN 200
210 IF A$ = "0" THEN AT = AT + 1
220 IF A$
=
"S" THEN AT
=
AT - 1
230 IF A$="E" THEN AT=AT-£10
2£10 IF A$="X" THEN AT=AT+£10
250 IF AT>=0 AND AT>=318 GO TO 300
260 PRINT CHR$(7l; : AT=A : GOTO 200
300 PRINT @ A, " "; : PRINT @ AT, "*";
310 A = AT : GO TO 200
Execute this program.
The asterisk should appear in the center of the display. Press
CIJ
and the asterisk
should move up. Press the
00
and the asterisk should move down.
120

Advertisement

Table of Contents
loading

Table of Contents