Sinclair QL User Manual page 116

Hide thumbs Also See for QL:
Table of Contents

Advertisement

Some Techniques
100
A second pOint ot Interest is that the array element, come(O), IS used for two purposes:
It carnes the number of items to be sorted
it is used to hold the Item currently being placed.
100 DEFine PROCedure sort(come,send)
110
LET num = come<O)
120
FOR item = 2 TO num
130
LET P = item
140
LET come
(0)
= come (p)
150
REPeat compare
160
IF come(O) >= come(p-1)
EXIT compare
170
LET come(p) = come(p-1)
180
LET P = p-1
190
END REPeat compare
200
LET come (p) = come (0)
210
END FOR item
220
FOR k=1 TO 7 : send(k) = come(k)
230 END DEFine
The follOWing additional lines will test the sort procedure. First type AUTO 10 to start
the line numbers from
10
onwards.
10 REMark Test Sort
20 DIM row$(7,3),back$(7,3)
30 LET row$(O) = 7
40 FOR k = 1 TO 7 : READ row$(k)
50 sOrt row$,back$
60 PRINT
I
back$
I
70 DATA "EEL
II
,
"DOG", "ANT", "GNU", "CAT", IlBUG", "FOX"
Output
ANT BUG CAT DOG EEL FOX GNU
COMMENT
This program illustrates how easily you can handle arrays in SuperBASIC All you have
to do is use the array names for passing them as parameters or for printing the whole
array. Once the procedure IS saved you can use MERGE mdv1_sort to add It to a
program in main memory
You now have enough understanding of techniques and syntax to handle a more complex
screen layout Suppose you wish to represent the hands of four card players. A hand
can be represented by something like:
H: A
37 Q
C. 5 9 J
D 610 K
S: 2 4
Q
To help the presentation the Hearts and Diamonds will be printed in red and the Clubs
and Spades in black. A suitable STRIP colour might be white. The general background
could be green and a table may be a colour obtained by mixing two colours.
METHOD
Since a substantial amount of character printing is involved it is best to start planning
in terms of the pixel screen. You can see that you need to provide for twelve lines of
characters with some space between lines and a total screen height of 256 pixels.
=
=
12/84

Advertisement

Table of Contents
loading

Table of Contents