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 #35 background imageLoading...
Page #35 background image
DIM high_st$(4, 3)
| |
| ------ maximum length of string
|
--------- number of string variables
After the DIM statement has been executed the variables are available for use. It is as though the
houses have been built but are still empty. The four 'houses' share a common name, high_st$, but
each has its own number and each can hold up to three characters.
There are five programs below which all do the same thing: they cause the four 'houses' to be
'occupied' and they PRINT to show that the 'occupation' has really worked. The final method uses
only four lines but the other four lead up to it in a way which moves all the time from known ideas to
new ones or new uses of old ones. The movement is also towards greater economy.
If you understand the first two or three methods perfectly well you may prefer to move straight onto
methods 4 and 5. But if you are in any doubt, methods 1, 2 and 3 will help to clarify things.
Program 1
100 DIM high_st$(4,3)
110 LET high_st$(l) = "VAL"
120 LET high_st$(2) = "HAL"
130 LET high_st$(3) = "MEL"
140 LET high st$(4) = "DEL"
150 PRINT ! high_st$(1) ! high st$(2) !
160 PRINT ! high_st$(3) ! high-st$(4) !
Program 2
100 DIM high st$(4,3)
110 READ high_st$(1),high_st$(2),high_st$(3),high_st$(4)
120 PRINT ! high_st$(1) ! high_st$(2) !
130 PRINT ! high_st$(3) ! high_st(4) !
140 DATA "VAL","HAL","MEL","DEL"
This shows how to economise on variable names but the constant repeating of high_st$ is both
tedious and the cause of the cluttered appearance of the programs. We can, again, use a known
technique - the REPeat loop to improve things further. We set up a counter, number, which increases
by one as the REPeat loop proceeds.
Program 3
100 RESTORE 190
110 DIM high_st$(4,3)
120 LET number = 0
130 REPeat houses
140 LET number = number + 1
150 READ high_st$(number)
160 IF num = 4 THEN EXIT houses
170 END REPeat houses
180 PRINT high_st$(1) ! high_st$(2) ! high_st$(3) ! high_st$(4)
190 DATA "VAL","HAL","MEL","DEL"
:

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