The ZX80 Operating Manual

Sinclair ZX Spectrum
People are very good at disentangling confused instructions and solving complex problems. A computer isn't all it can do is to follow a list of instructions and carry out the instructions as it comes to them.

As an example, take the following instructions which a mother might give to her child:

"Could you run down to the shop and buy some bread? Take 50p which is in my purse on the kitchen table. And for goodness sake get dressed!"

It all seems quite clear; the child knows where to go, what to buy and where the money is. A computer controlled robot would take the first instruction:

run down the shop, and do that.

The second instruction: buy some bread. It can't do that (no money) and at this stage would probably just stop, baffled.

The third instruction: take 50p from the purse, it can't do that.

The fourth instruction: go to the kitchen table. It returns home and goes to the kitchen table. Then the fifth instruction: get dressed.

It gets dressed.

A child would instinctively carry out the instructions in the following order:

1. Get dressed
2. Go to the kitchen table
3. Take 50p from the purse
4. Go to the shop
5. Buy some bread

He or she would come back home!

The mother in this example missed out one vital instruction ("come home") as well as putting the instructions in an illogical order. Children use commonsense to interpret complex instructions, but computers can't do this. You have to do all the thinking in advance when you use a computer. So remember:


One way of making sure that you are thinking straight is by drawing a flow diagram before you start to do any actual programming. This helps you get things in the right order to begin with.

The flow diagram for the example above would look like this:

  Get Dressed  
  Take 50p From The Purse  
  Go To The Shop  
  Buy Some Bread  
  Return Home  

Each box contains an instruction, and the arrows show the order in which the instructions are executed. Well. that looks pretty simple and neat. Now that the flow diagram is drawn on paper we can check it by going through the boxes one by one and asking ourselves: Can the child (or the computer) do this?

Starting with the first box (get dressed) we might think that it's pretty basic. On the other hand, the child may not be able to find his clothes because his naughty sister has thrown them out of the bedroom window. Perhaps we should add an instruction (find clothes) at the beginning of the program.

Go to the kitchen table: well, that looks OK.

Take 50p from purse: what happens if the purse is empty? Go to the shop: does the child know where the shop is? Buy some bread: what sort?

Return home: nothing much wrong with that!

Maybe the flow diagram wasn't as good as we thought. Even simple tasks can turn out to be more complicated than we think.

Most of the problems which we've spotted are due to a lack of information and this can be coped with by adding extra instructions at the beginning of the program. These could include:

1. Ask where the shop is
2. Find clothes

When you are writing programs for the ZX-80 it is particularly important to give the computer all the information it needs before it has to carry out a task. For instance, if you ask it to PRINT a variable the computer must know the value of the variable.

Now for some arithmetic.

Sinclair ZX Spectrum

  Previous Page Back Next Page