Commodore VIC-20 User Manual page 107

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

Experiment with this program. You can make the defays
between displaying and erasing your name longer or shorter by
changing the number 300 in lines 20 and 40.
PROGRAM 2: A Lot of Heart
(Chapter 3)
10
20
30
40
50
60
70
80
FOR H
PRINT
NEXT
FORC
POKE
FORT
NEXT
GOTO
= 1
= 8
TO
r
TO
36879,(
= 1
40
TO
505
255 STEP 17
500: NEXT
This program provides you with a colorful display of hearts. It
introduces the use of punctuation marks in PRiNT statements
and the use of POKE to change the screen and border colors.
Line 10 sets up a loop that counts from 1 to 505. We want 505
hearts to appear on the screen, because there are 506 spaces
on the screen. If we PRINTed the 506th character, the screen
would be forced to roll up one line (scrolling), and there would
be less hearts on the screen than before.
Line 20 PRINTs the heart character on the screen. The semi
colon (;) after the iast quote has an important effect. You see,
after a normal PRINT statement, the VIC wilf automaticafly
perform 2 operations — move the cursor back to the beginning
of the line (called a carriage return), and move the cursor down
to the next line {called a linefeed). The punctuation mark at the
end of the line wiil cancel the return and linefeed, so that the
next thing PRINTed wifl appear immediately to the right of the
last thing PRINTed.
Line 30 just completes the delay loop. As fong as the value of H
is 505 or less, the program will print hearts on the screen. When
the 505th is printed, the program continues with the line after
this one (line 40).
97

Advertisement

Table of Contents
loading

Table of Contents