home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / sourcecode / general / card-generator.amos / card-generator.amosSourceCode
Encoding:
AMOS Source Code  |  1993-08-02  |  884 b   |  37 lines

  1. ' This programs shuffles and generates a deck of cards using strings only
  2. Screen Open 0,640,256,2,Hires : Colour 1,$FFF
  3. Dim C$(52),CO(52)
  4. Global C$(),CO()
  5. SETUP
  6. _RANDOM[52,52]
  7. For X=1 To 52 : Print X;" ";C$(CO(X)) : Next X
  8. Procedure SETUP
  9.    Z=1 : Dim CD$(4)
  10.    CD$(1)=" Of Hearts"
  11.    CD$(2)=" Of Diamonds"
  12.    CD$(3)=" Of Clubs"
  13.    CD$(4)=" Of Spades"
  14.    For C=1 To 4
  15.       C$(Z)="ACE"+CD$(C) : Inc Z
  16.       For X=2 To 10
  17.          C$(Z)=Str$(X)-" "+CD$(C) : Inc Z
  18.       Next X
  19.       C$(Z)="Jack"+CD$(C) : Inc Z
  20.       C$(Z)="Queen"+CD$(C) : Inc Z
  21.       C$(Z)="King"+CD$(C) : Inc Z
  22.    Next C
  23. End Proc
  24. Procedure _RANDOM[HN,NRN]
  25.    If NRN>HN Then Pop Proc
  26.    Randomize Timer
  27.    Z=1
  28.    Repeat 
  29.       L:
  30.       RN=Rnd(HN) : If RN=0 Then Goto L
  31.       If Z=1 Then CO(Z)=RN : Inc Z
  32.       For X=1 To Z
  33.          If RN=CO(X) Then Goto L
  34.       Next X
  35.       CO(Z)=RN : Inc Z
  36.    Until Z=NRN+1
  37. End Proc