Typing A Program In
For starters, type in what you see below. After each line, press the "Return" key.
10 PRINT"JACK AND JILL" 20 PRINT"WENT UP THE HILL"Because you started each line with a number, the computer stored these lines into its memory used for programs.
Displaying Your Current Program
Clear the screen (by pressing Shift and Clr/Home simultaneously), then type LIST
and press the "Return" key. As you can see, the computer remembers what you had typed in. Now, type
the following line and press "Return":
15 PRINT"MET WITH BILL AND"Type
LIST
again, and you will notice that the computer inserted that line in proper
numerical order. In large programs, however, you may not want to LIST the entire contents of the
program. For these situations, you can specify which lines you want LISTed. Try the following:
LIST | Display the entire program |
LIST 10 | Display only line 10 |
LIST -15 | Display everything before and including line 15 |
LIST 15- | Display line 15 and everything after it |
LIST 15-20 | Display lines 15 through 20, inclusive |
Do Something, Already!
The point of programming is not to store a program, but to execute it! Clear the screen again, and
type the blessed command RUN
, followed by the "Return" key. This will command the
computer to go through your program and execute the commands that you typed in it. In this case, our
program uses the PRINT command to display 3 lines of text. Your
screen should now look something like this:
RUN JACK AND JILL MET WITH BILL AND WENT UP THE HILL READY.The
RUN
command can also be told which line to start the program at. Usually, it just
starts executing from the first line of the program. But if you want to skip ahead and start at a
later point, simply type the line number you want to start at after the RUN
command:
RUN 15 MET WITH BILL AND WENT UP THE HILL READY.Editing
Nobody writes perfect programs on the first try (not even John Iannetta!), so we need some way of changing an existing program without having to rewrite it. To change a line of code, simply type a line with the same line number, and the new content will replace the old:
20 PRINT"PICKED THEIR COLLECTIVE NOSES"
LIST
the program again, and it will show that we replaced line 20. For short changes,
you can LIST
a line, move the cursor over the line and make your changes, then press
the "Return" key. It is very important that you press "Return" or your change will not be recorded.
LIST
line 15, move the cursor over the "B", and type "W" to change Bill's name to Will.
Press "Return", clear the screen, and LIST
or RUN
the program to see the
result of the edit.Starting Over
The NEW
command erases the current program from memory, should you want to start from
scratch. Use this command very carefully. Though the BASIC memory can be reconstructed using very
advanced low-level techniques, for all practical purposes the program is gone.