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 #53 background imageLoading...
Page #53 background image
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 REPeat 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.
Example (i).
100 FOR even = 2 TO 10 STEP 2
110 PRINT ! even !
120 END FOR even
output is 2 4 6 8 10
Example (ii).
100 FOR backwards = 9 TO 1 STEP -1
110 PRINT ! backwards !
120 END FOR backwards
output is 9 8 7 6 5 4 3 2 1
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' ! row
130 FOR cross = 1 TO 10
140 PRINT ! 'X' !
150 END FOR cross
160 PRINT
170 PRINT \ 'End of row number' ! 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 3
A big advantage of SuperBASIC is that it has structures for all purposes, not just FOR loops, and they
can all be nested one inside the other reflecting the needs of a task. We can put a REPeat loop in a

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