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 #43 background imageLoading...
Page #43 background image
PASSING INFORMATION TO PROCEDURES
Suppose we wish to draw squares of various sizes and various colours in various positions on the
scale graphics screen.
If we define a procedure, "square", to do this it will require four items of information:
length of one side
colour (colour code)
position (across and up)
The square's position is determined by giving two values, across and up, which fix the bottom left
hand corner of the square as shown below.
The colour of the square is easily fixed but the square itself uses the values of side and ac and up as
follows.
200 DEFine PROCedure square(side,ac,up)
210 LINE ac,up TO ac+side,up
220 LINE TO ac+side,up+side
230 LINE TO ac,up+side TO ac,up
240 END DEFine
In order to make this procedure work values of side, ac and up must be provided. These values are
provided when the procedure is called. For example you could add the following main program to get
one green square of side 20.
100 PAPER 7:CLS
110 INK 4
120 square 20,50,50
The numbers 20,50,50 are called parameters and they are passed to the variables named in the
procedure definition thus:
The numbers 20,50,50 are called actual parameters. They are numbers in this case but they could
be variables or expressions. The variables side, ac, up are called formal parameters. They must be
variables because they 'receive' values.
A more interesting main program uses the same procedure to create a random pattern of coloured
pairs of squares. Each pair of squares is obtained by offsetting the second one across and up by one-
fifth of the side length thus:

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