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 #61 background imageLoading...
Page #61 background image
ii.
•
•
•
sample output:
Row
numbe r 1
811637
End
of
row
numbe r
Row
number 2
462945127
End
of
row number 2
Row
numbe r 3
7
End
of
row
number 3
Row
number 4
624997
End
of
row
number 4
The third feature of loops
in
SuperBASIC allows more flexibility
in
providing the range
of values
In
a FOR loop. The following program illustrates this by printing
all
the divisible
numbers from 1
to
20.
(A
divisible number
is
divisible evenly by a number other than
itself or
1.)
100
REMark
Divisible
numbers
110
FOR
num
=
4,6,8,
TO
10,12,14
TO
16,18,20
120
PRINT I
num
I
130
END
FOR
num
More will be said about handling repetition
in
a later chapter but the features described
above will handle
all
but a
few
uncommon or advanced situations.
You
will
have noticed the simple type of decision:
IF
die
= 6
THEN
EXIT
throws
This
is
available
in
most BASICs but SuperBASIC offers extensions of
thiS
structure and
a completely new one
for
handling situations with more than two alternative courses
of action.
However you may find the following long forms
of
IF
...
THEN useful. They should explain
themselves.
100
REMark Long
form
IF
...
END
IF
110
LET
sunny
=
RND
(Q
TO
1)
120
I F
sunny
THEN
130
PRINT
'Wear
sunglasses'
140
PRINT 'Go
for
waLk'
150
END
IF
100
REMark Long
form
IF
..•
ELSE
...
END
IF
110
LET
sunny
=
RND(O
TO
1)
120
I F
sunny
THEN
130
PRINT
'Wear
sunglasses'
140
PRINT 'Go
for
waLk'
150
ELSE
160
PRINT
'Wear
coat'
170
PRINT
'Go
to
cinema'
180
END
IF
The separator THEN,
IS
optional
in
long forms or
it
can be replaced by a colon
in
short
forms. The long decision structures have the same status as loops.
You
can nest them
or put other structures into them. When a single variable appears where you expect
a condition the value zero
will
be taken
as
false and other values
as
true.
Most BASICs have a GOSUB statement which may be used
to
activate particular blocks
of code called subroutines. The GOSUB statement
is
unsatisfactory
In
a number of
ways
and Super
BASIC
offers properly named procedures
With
some very useful features.
Consider the following programs both of which draw a green 'square' of side length
50 pixel screen units at a position 200 across 100 down
on
a red background.
12/84
From
Basic
to
SuperBASIC
DECISION
MAKING
SUBROUTINES
AND
PROCEDURES
45

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