Commodore PET User Manual page 247

Table of Contents

Advertisement

Without the semicolons. the PET performs a carriage return after each statement
and the top line will look like this:
r
-,
The other three sides are drawn in a sequence similar to lines 10 and 15.
Line 20 begins the next sequence. then converts the linear segment to
FOR ... NEXT/PRINT statements. calling the time delay subroutine in that PRINT
loop. Don't forget to include the cursor controls to compensate for the automatic
right cursor movement inside the FOR... NEXT loops for the vertical sides of the
square:
F'RHlT" '00"
right si de PRINT<RIGHT L1NE VERT. ><CURSOR L. >
<CURSOR DOWN>
F'RINT"-I••"
botlom
PRINT<BOTTOM L1NE HORIZ.><CURSOR L.>
<CURSOR
L.
>
F'F<:INT"lln"
leftside
PRINT<LEFT L1NE VERT. ><CURSOR L. >
<CURSOR UP>
The program listing looks like this:
5 F'R 1NT":']" .;
1 (1 F'R 1NT" r".; : GOSLIE: 1 (1JC:1
15 FOR l=lTO 5:F'RINT"-".; : GOSUB l(t(t:NEXT 1
2(1 F'R 1tH" 1".; : GOSUB 1 JC:1(t
25 FOR 1 = 1TO 5: F'R 1t·lT" '[!!l".; : GOSUB 1 €l(t :
NE>~T
1
30 F'RItH
"...J" .; :
GOSUB 1130
35 FOF.: 1= 1 TO 5: F'R 1NT"
-1.1"; : GOSUB 1(10 : NEXT 1
413 F'R 1NT"
L".; :
GOSLΠ1 (113
45 FOR l=lTO S:F'RIHT"lln".; : GOSUB l(t0:NE>::T 1
5(1 ENII
11313 FOR S= 1 TO 113:
l'~E;:'::T
~T:
RETURN
Now. try a trial run. Does your square look like this?
1
Il
F.:EAII'y'.
1
1
1
1
1
1
1
LI _ _
If this design appeared instead of a perfect square. some of the cu rsor controls
were left out. The PET did exactly what it was programmed to do. so where is the
problem? Take a closer look at the program. We included cursor controls within
the FOR... NEXT loops for ail four sides of the square. Now look at the screen. The
problem is not with the sides. The problem. therefore. must be in the corners.
Look at statements 20. 30. and 40. We forgot the cursor con trois after each corner
234

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents