PRINT, RUN, GOTO, and LIST
If you do not have a Commodore 64 then try an emulator. The best emulator for your computer is VICE. If you don't want to download and install VICE, then you can use this online emulator. It's not the best, but it will work. A new machine was made fairly recently that is called "The C64 Mini". The C64 Mini is like newer version of the original 64 so you can use that instead. If you are using an emulator, some of the keys (like punctuation marks) might not be where you expect, so be warned.
I am now going to tell you about the BASIC commands and coding for beginners.
There are two different modes for communicating with the machine. The first mode is called immediate mode
(it can also be called direct mode.) The second mode is called program mode. In immediate mode, you type
in commands, and when you press RETURN, the computer responds right away. In program mode, you make your own program
that is stored in RAM (memory) so you can RUN
it later.
The first command I will tell you about is PRINT
. PRINT
is used to output to the screen.
Whatever you tell the computer to type will show up on the monitor.
Here are some things you could try with the PRINT
command:
PRINT "IAN SKINNER CREATED THIS WEBSITE"
- You can print your name or a sentence, but you have to have quotation marks around what you want the computer to print.
PRINT 13
- You can print numbers, and you don't need quotation marks.
PRINT 11111*11111
- You can print arithmetic problems and use
PRINT
like a calculator. Type the problem you want the answer to and type return. The computer will print the answer. PRINT "EWHITE £RED ↑GREEN"
- You can also print colour change codes and other special characters. I will explain what these are in a later on.
If you wanted to make an actual program in program mode, then you have put numbers at the beginning of each line of your program. Try
typing 10 PRINT"COMMODORE"
and press RETURN. You can use a question mark as a short form for PRINT
, so you
could type 10 ?"COMMODORE"
and it means the same thing. After you press RETURN,
it looks like nothing happened, but what actually happened is the computer knows that you finished your line of code and it is stored in RAM.
The line number tells the computer what order your program lines should go in. The numbers
can go up from 0 to 63999. If you want your computer to type "COMMODORE", then you would have to use the RUN
command.
This command is used for running programs that are stored in memory.
Let's add a line to our program. Type 20 GOTO 10
. This line will be put right after line number
10. If you want to see what you have so far in your program, just type LIST
and then press RETURN.
You will see the entire program you have written. To execute the program, type RUN
and press
RETURN. If you have more than one line in the program, the computer goes from the first line to the last line
in the order of the line numbers. The instruction GOTO 10
tells the machine to go back to line
10 and run forward from there.
Now, if you type RUN
, then the program will go in an endless loop until you press the STOP key.
When you press STOP, it says BREAK IN 10
, but it does not mean anything is broken. All it means is just that the computer is taking a break from
running your program, and in this case it stopped at line 10.
Next, I will tell about how to get colours on your screen.