Sinclair QL Beginner's Manual page 10

Hide thumbs Also See for QL:
Table of Contents

Advertisement

1. Names such as dogs, days and tins are called identifiers.
2. A single instruction such as:
LET dogs = 9 
is called a statement.
3. The arrangement of name and associated pigeon hole is called a variable. The execution of
the above statement stores the value 9 in the pigeon hole 'identified' by the Identifier dogs.
A statement such as:
LET dogs = 9 
is an instruction for a highly dynamic internal process but the printed text is static and it uses the =
sign borrowed from mathematics. It is better to think or say (but not type):
LET dogs become 9 
and to think of the process having a right to left direction (do not type this):
dogs  9
The use of = in a LET statement is not the same as the use of = in mathematics. For example, if
another dog turns up you may wish to write:
LET dogs = dogs + 1 
Mathematically this is not very sensible but in terms of computer operations it is simple. If the value of
dogs before the operation was 9 then the value after the operation would be 10. Test this by typing:
LET dogs = 9 
PRINT dogs 
LET dogs = dogs + 1 
PRINT dogs 
The output should be:
9
10
proving that the final value in the pigeon hole is as shown:
dogs
9
A good way to understand what is happening to the pigeon holes, or variables, is to do what is called
a "dry run". You simply examine each instruction in turn and write down the values which result from
each instruction to show how the pigeon holes are set up and given values, and how they retain their
values as the program is executed.
LET dogs = 9 
LET days = 28 
LET tins = dogs * days 
PRINT tins
The output should be

Advertisement

Table of Contents
loading

Table of Contents