Commodore PET User Manual page 118

Table of Contents

Advertisement

RETURN presents a special problem that other keys do not. You cannot reference
RETURN as a string literai:
H ] " . . . - --
Cannat do
This is because any time RETURN is pressed. PET BASIC stores the program line
in memory and goes to the beginning of the next line. You can, however, use the
CHR$ function to check for a RETURN key. CHR$ allows vou to assign an ASCII
code value to a string variable and treat it as a string. The ASCII code value for a
RETURN (referring to Appendix A) is 13.
Before programming the check for carriage return, consider what to do if
there is one. The last line of the program branches back to the beginning of the
program. To terminate program execution, vou need to branch beyond that. Add
the following line:
17(1 END
Now add the check for RETURN as line 105:
1(15 IF C$=CHR$(13) GOTO 17(1
Note that we could have written. in place of line 170 and line 105:
1 (15 1 F C$=CHF.:$ ( 1 :::::) THEN Hm -
Option
If vou choose this option. it is generally good programming practice to have
the program termination point at the physical end of the program. It is more
difficu It to find termination points embedded in the program.
Without the PETs READY message being printed each time. there are two
additional lines available on the screen. This allows 80 more characters (at 40
characters per line) to be printed. Change the 840 in line 120 to 840+80=920.
Line 120 will read:
120 FOR 1=1 TO 920
List the program: it should look like this:
LIST
90 PRINT "HIT A KEY"
100 GET CS: IF C$:::"" GOTO lü(1
1(15 IF C$=CHR$(13) GOTO
110
Ile PRHn
"j".:
120 FOR 1=1 TO 920
130
PF~I~n
C:$:.;
141;1 t·jE:>n
151;1 PF.:
1
NT "PHEI·J!"
160 OOTO 90
170
E~m
F.:EADY.
105

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents