EasyManuals Logo

Sinclair QL Beginner's Guide

Sinclair QL
135 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 #52 background imageLoading...
Page #52 background image
;
just separates - no formatting effect
\
forces new line
!
normally provides a space but not at the start of line. If an item will
not fit at the end of a line it performs a new line operation.
TO
Allows tabulation to a designated column position.
You will be familiar with two types of repetitive loop exemplified as follows:
(a) Simulate 6 throws of an ordinary six-sided die
100 FOR throw = 1 TO 6
110 PRINT RND(1 TO 6)
120 NEXT throw
(b) Simulate throws of a die until a six appears.
100 die = RND(1 TO 6)
110 PRINT die
120 IF die <> 6 THEN GOTO 10
Both of these programs will work in SuperBASIC but we recommend the following instead. They do
exactly the same jobs. Although program (b) is a little more complex there are good reasons for
preferring it.
Program (a)
100 FOR throw = 1 TO 6
110 PRINT RND(1 TO 6)
120 END FOR throw
Program (b)
100 REPeat throws
110 die = RND(1 TO 6)
120 PRINT die
130 IF die = 6 THEN EXIT throws
140 END REPeat throws
It is logical to provide a structure for a loop which terminates on a condition (REPeat loops) as well as
those which are controlled by a count.
The fundamental REPeat structure is:
REPeat identifier
statements
END REPeat identifier
The EXIT statement can be placed anywhere in the structure but it must be followed by an identifier to
tell SuperBASIC which loop to exit; for example:
EXIT throws
would transfer control to the statement after
END REPeat throws.
This may seem like a using a sledgehammer to crack the nut of the simple problem illustrated.
However the REPeat structure is very powerful. It will take you a long way.

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