EasyManuals Logo

Sinclair QL User Manual

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
Page #60 background imageLoading...
Page #60 background image
From
Basic
to
SuperBASIC
If
you know other languages you may
see
that
it
will
do the
Jobs
of
both REPEAT and
WHILE structures and also cope with
other,
more awkward, situations.
The SuperBASIC REPeal loop
is
named so that a correct clear exit
is
made. The FOR
loop,
like
all
SuperBASIC structures, ends
with
END, and
its
name
is
given for reasons
which
will
become clear
later.
You
will
also
see
later how these loop structures can be used
in
simple or complex
situations
to
match exactly what
you
need
to
do.
We
will
mention only three more features
of
loops
at
this
stage.
They
will
be familiar
if
you
are
an
experienced user
of
BASIC.
The
increment
of
the control variable
of
a FOR loop
IS
normally 1 but you can make
It
other values by using the STEP keyword.
As
the examples show
100
FOR
even
= 2
TO
10
STEP 2
110
PRINT I
even
I
120
END
FOR
even
output
is
2 4 6 8
10
Ii.
100
FOR
backwards
=9
TO
1
STEP-1
110
PRINT
I
backwards
I
120
END
FOR
backwards
output
is
9 8 7 6 5 4 3 2
The second feature
IS
that loops can be nested.
You
may be familiar with nested FOR
loops.
For
example the following program outputs four
rows
of
ten crosses.
100
REMark
Crosses
110
FOR
row
=1
TO
4
120
PRINT
'Row
number'l
row
130
FOR
cross
= 1
TO
10
140
PR
I
NT
I'
X' I
150
END
FOR
cross
160
PRINT
170
PRINT \
'End
of
row
number'
I
row
180
END
FOR
row
output
is
Row
number
1
X X X X X X X X X X
End
of
row
number
1
Row
number
2
X X X X X X X X X X
End
of
row
number
2
Row
number
3
X X X X X X X X X X
End
of
row
number
3
Row
number
4
X X X X X X X X X X
End
of
row
number
4
44
A big advantage
of
Super
BASIC
is
that
it
has structures for
all
purposes, not
Just
FOR
loops, and lhey can
all
be nested one inside the other relfecling the needs
of
a
task.
We
can put a REPeat loop
in
a FOR loop. The program below produces scores
of
two dice
in
each row until a seven occurs, instead
of
crosses.
100
REMark
Dice
rows
110
FOR
row
= 1
TO
4
120
PRINT
I
Row
number
'.1
row
130
REPeat
throws
140
LET
die1
=RND(1
TO
6)
150
LET
die2
= RND(1
TO
6)
160
LET
score
=
die
1 +
die2
170
PRINT
I
score
I
180
IF
score
=7
THEN
EXIT
throws
190
END
REPeat
throws
200
PRINT
\'End
of
row'
I
row
210
END
FOR
row
12/84

Other manuals for Sinclair QL

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair QL and is the answer not in the manual?

Sinclair QL Specifications

General IconGeneral
ProcessorMotorola 68008
Clock Speed7.5 MHz
RAM128 KB (expandable to 640 KB)
ROM48 KB
Operating SystemSinclair QDOS
Release Year1984
StorageMicrodrive tape loop
Graphics256x256 pixels, 8 colors
PortsRS-232, ROM cartridge
SoundBeeper (internal speaker)

Related product manuals