EasyManua.ls Logo

Sinclair QL - Page 32

Sinclair QL
422 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Drawing
on
the
Screen
A
SIMPLE
LOOP
Computers can
do
things very qUickly but
it
would not be possible
to
exploit this great
power
If
every action had
to
be written
as
an
Instruction. A building foreman has a similar
problem.
If
he wants a workman
to
lay a hundred paving stones that
is
roughly what
he
says.
He does not give a hundred separate Instructions.
A traditional
way
of
achieving looping or repetition
In
BASIC
is
to
use
a GO
TO
(or
GOTO,
they
are
the same) statement
as
follows:
NEW"II
10
PAPER 6 : CLS
..
"
20
BORDER
1,2
..
'
30
INK
RND(5)
..
',
40
LINE
50,60
TO
RNDC10OJ,
RND(100)
..
,
50
GOTO
0
..
",
RUN
.11
You
may prefer not
to
type
in
this program because SuperBASIC allows a better way
of
dOing
repetition. Note certain things about each
line.
~~
~~~p~a~rt_'
-
~~=t
=-re-pe_at_ed'
'I
I"
----------'-1
~~
L~han~e
part_--:
repeated.J
50
~ntrols
pr6gr~~~=
You
can
re-write
the above program
by
omitting
the
GOTO
statement and, instead, putting
REPeat and END REPeat around the part
to
be repeated.
NEW"II
10
PAPER 6 :
CLS
..
"
20
BORDER
1
,2
..
"
30
REPEAT
star
..
"
40
INK
RND(5)
..
"
50
LINE
50,60
TO
RND(100),
RND(100)
..
"
60
END
REPEAT
star
..
"
RUN
"It
We
have give the repeat
structure
a name,
star.
The structure consists of the two lines:
REPeat star
END REPeat star
and what lies between them
is
called the content of the structure The use of upper
case letters Indicates that REP
IS
a valid abbreviation of REPeal.
This program should produce coloured lines Indefinitely
to
make a star as shown
in
the
figure
below.
16
The
STAR
program
You
can stop
it
by pressing the break
keys:
Hold down I CTRL I and then press
rl
-~S"'P"'1>."C"E~----'
12/84

Other manuals for Sinclair QL

Related product manuals