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 #11 background imageLoading...
Page #11 background image
252
You may notice that so far a variable name has always been used first on the left hand side of a LET
statement. Once the pigeon hole is set up and has a value, the corresponding variable name can be
used on the right hand side of a LET statement.
Now suppose you wish to encourage a small child to save money. You might give two bars of
chocolate for every pound saved. Suppose you try to compute this as follows:
LET bars = pounds * 2
PRINT bars
You cannot do a dry run as the program stands because you do not know how many pounds
have been saved.
We have made a deliberate error here in using pounds on the right of a LET statement without it
having been set up and give n some value. Your QL will search internally for the variable "pounds". It
will not find it, so it concludes that there is an error in the program and gives an error message. If we
had tried to print out the value of "pounds", the QL would have printed a * to indicate that "pounds"
was undefined. We say that the variable pounds has not been initialised (given an initial value). The
program works properly if you do this first.
bars
pounds
LET pounds = 7
7
LET bars = pounds * 2
7
14
The program works properly and gives the output:
14
A STORED PROGRAM
Typing statements without line numbers may produce the desired result but there are two reasons
why this method, as used so far, is not satisfactory except as a first introduction.
1. The program can only execute as fast as you can type. This is not very impressive for a machine
that can do millions of operations per second.
2. The individual instructions are not stored after execution so you cannot run the program again or
correct an error without re-typing the whole thing.
Charles Babbage, a nineteenth century computer pioneer knew that a successful computer needed to
store instructions as well as data in internal pigeon holes. These instructions would then be executed
rapidly in sequence without further human intervention.
The program instructions will be stored but not executed if you use line numbers. Try this:
10 LET price = 15
20 LET pens = 7
30 LET cost = price * pens
40 PRINT cost
Nothing happens externally yet, but the whole program is stored internally. You make it work by
typing:

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