MODULE cards

 

!modules are similar to libraries:

!any procedure not labeled

!PRIVATE may be used in the same way

!that external procedures are normally used.

!If the procedure is a function, a

!DECLARE DEF statement is required.

 

!To use PUBLIC variables or arrays,

!you must include a DECLARE PUBLIC

!statement which identifies those

!variables and arrays you wish to use.

!An array named in such a declaration

!must include empty parentheses,

!as if it were a parameter

!in a procedure definition.

 

!this module shuffles 51 cards in 4 suits,

!and deals as many cards as

!required by the main program.

 

 

SHARE card(0 to 51),n !deck,cards left

SHARE val$(0 to 12), suit$(0 to 3) !values,suits

PRIVATE decipher

 

MAT READ val$, suit$

DATA two, three, four, five, six, seven, eight

DATA nine, ten, jack, queen, king, ace

DATA clubs, diamonds, hearts, spades

RANDOMIZE

CALL shuffle

SUB shuffle

FOR i = 0 to 51

LET card(i) = i

NEXT i

LET n=52

END SUB

SUB deal(c)

LET j=int(n*rnd)

LET c=card(j)

LET n=n-1

LET card(j)=card(n)

END SUB

DEF name$(c)

CALL decipher(c,v,s)

LET name$=val$(v) & " of " & suit$(s)

END DEF

SUB decipher(c,v,s)

CALL divide(c,13,s,v)

END SUB

END MODULE