Commodore 2001-8 User Manual page 27

Table of Contents

Advertisement

constitute a program which tells the PET to print out HI THERE.
The program is now resident in memory. To execute the program, type RUN. This gives us the HI THERE
printed in the vertical format:
H
I
T
H
E
R
E
You will note that we do not have a space between the I and T. One of the reasons we use the numbers in
the multiple of ten is that we can now insert a correction between lines 20 and 30. First, display the
program by typing LIST. This gives us the program printed as follows:
10? PRINT "H"
20? PRINT "I"
30? PRI NT "T"
40? PRINT "H"
50? PRINT "E"
50? PRINT "R"
70? PRINT "E"
Now type:
25?""
Press return and relist the program, and we will see that line 25 is inserted between lines 20 and 30. If we
run the program now, we get:
H
I
T
H
E
R
E
This example demonstrates the use of line numbers and the ability to insert lines numbers to make a
correction in a program.
There is another way to get the same effect. First delete the space by typing 25 followed by a carriage
return. Then list the program and see that line 25 has been deleted. Now position the cursor on the space
following the I on line 20, and insert a cursor down. First by hitting the insert key, and then the cursor
down key, if you don't hit the insert key first, the cursor will move down immediately. But because you
inserted the cursor-down (it looks like a reverse field
Q),
the cursor will not move until instruction 20 is
executed. Do not forget to hold down shift before striking insert.
When we now run the program, you see this also gives you the effect if a space on the next line. This
would not always be true, except we had been cheating and using the automatic scrolling capability of
the PET which clears out the field. Had we programmed a home prior to printing a program, we would not
have received such a nice result. Try programming a home 5?"HOME", then try a clear 5?"ClEAR".
The screen editor will allow you to take
a
program and make changes on any of the lines you display on
the screen. The list command has several features to help you get the right lines to the screen to edit. List
takes programs and prints the contents of the basic program which is stored in memory. The command
L·I·S·T starts at the first line number in memory and lists to the screen device all the instructions to the
23

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents