Sinclair QL Beginner's Manual page 125

Hide thumbs Also See for QL:
Table of Contents

Advertisement

ac,dn
cursor position for characters
row
current row for characters
lin$
builds up row of characters
max
highest card number
p
points to card position
n
current number of card
PROCEDURES
Shuffle
shuffles 52 cards
Split
splits cards into four hands and calls sortem to sort each hand
Sortem
sorts 13 cards in ascending order
Layout
provides background colour border and table
Printem
prints each line of card symbols
Getline
gets one row of cards and converts numbers into the symbols
A,2,3,4,5,6,7,8,9,T,J,Q,K
PROGRAM DESIGN OUTLINE
1. Declare arrays, pick up 'tokens' and place 52 numbers in array card.
2. Shuffle cards.
3. Split into 4 hands and sort each.
4. OPEN screen window.
5. Fix the screen layout.
6. Print the four hands.
7. CLOSE the screen window.
100 DIM card(52),sort(13),tok$(4,2)
110 FOR k = 1 TO 4 : READ tok$(k)
120 FOR k = 1 TO 52 : LET card(k) = k
130 shuffle
140 split
150 OPEN #6,scr_440x220a35x15
160 layout
170 printem
180 CLOSE #6
190 DEFine PROCedure shuffle
200
FOR c = 52 TO 3 STEP -1
210
LET ran = RND(1 to c-1)
220
LET temp = card(c)
230
LET card(c) = card(ran)
240
LET card(ran) = temp
250
END FOR c
260 END DEFine
270 DEFine PROCedure split
280
FOR h = 1 TO 4
290
FOR c = 1 TO 13
300
310
END FOR c
320
sortem
330
FOR c = 1 TO 13
340
350
END FOR c
360
END FOR h
370 END DEFine
380 DEFine PROCedure sortem
390
FOR item = 2 TO 13
400
LET dart = item
410
LET comp = sort(dart)
420
LET sort(0) = comp
LET sort(c) = card((h-1)*13+c)
LET card((h-1)*13+c) = sort(c)

Advertisement

Table of Contents
loading

Table of Contents