Download Print this page

Commodore 64 User Manual page 44

Hide thumbs Also See for COMMODORE 64:

Advertisement

NUMBERS IN PROGRAMS
Try this procedure now by creating your own
simple program. First, type the following line
and press RETURN. (Although the command
won't be executed immediately, you still need
to press RETURN to send the command into
your computer's memory.) Do not worry if
your words wrap onto the next line; just press
RETURN at the end of the sentence.
10 REM NUMBER KEYS HAVE MANY USES.
The sentence now appears on your screen.
SCREEN 1
The 10 is the number now assigned to this
command line. It will be obeyed after any pro
gram line numbered 0 through 9, and before
any program line beginning with a larger num
ber. REM is an abbreviation of the word
REMARK, which tells the computer that this
line is extra information—a comment for your
benefit only.
Now, add the following two lines to your
program. Be sure to use the letter I, not the
number I. Use the
=
key for the equals sign.
20 I = 8 - 4
(press RETURN)
30 PRINT I
[press RETURN)
Now your screen shows three program lines.
SCREEN 2
You are now ready to run your first programl
To do this, type the word RUN and then press
the RETURN key.
What has happened? The computer read the
three program lines it had stored in its mem
ory. The first line is only a comment and does
not do anything. The next line tells the com
puter the value of I (8 - 4J. The last line
instructs the computer to print the value of I,
which is 4.
SCREEN 3
A note to remember: If you were to create a
new program using the same line numbers as
a program you previously created—in this
case, 10,20, and 30—each new program line
would take the place of the old one, wiping the
old line out of its memory. Also, if you were to
create a program and turn off the computer
without saving the program on a cassette or
diskette, the program would be gone until you
created it again. Once you turn off the com
puter, any program in its memory is erased.
Before going on to the next exercise, dear
the screen by holding down a SHIFT key and
pressing the CLR/HOME key.
±8
RETt-)
E
MAN V
NUMBER
USES
SCREEN 1
Use numbers to tell the computer the order
In which to perform commands In a program.
w
SCREEN 2
Give each command line In your program its
own unique number.
1 tO
REM
MRNV
,30
PR INT
■RUN
REftDV.
NUMBER
USES
KEVS
H,,V
_
o
SCREEN 3
When you type RUN and press RETURN, the
computer performs the commands and dis
plays the answer.
42

Advertisement

loading

Related Products for Commodore COMMODORE 64

This manual is also suitable for:

Vic 20