DECLARE SUB myTrivia (rAns$, jQuestion$, jAns1$, jAns2$, jAns3$, jAns4$)
DECLARE SUB finish ()

SCREEN 12
DIM SHARED right
DIM SHARED wrong

' the questions start...

jQuestion$ = "How many teams is there in the NHL?"
jAns1$ = "26"
jAns2$ = "6"
jAns3$ = "28"
jAns4$ = "32"
rAns$ = "C"
CALL myTrivia(rAns$, jQuestion$, jAns1$, jAns2$, jAns3$, jAns4$)

jQuestion$ = "How many CANADIAN teams are there in the NHL?"
jAns1$ = "15"
jAns2$ = "6"
jAns3$ = "3"
jAns4$ = "8"
rAns$ = "b"
CALL myTrivia(rAns$, jQuestion$, jAns1$, jAns2$, jAns3$, jAns4$)

finish

SUB finish
PRINT "The wonderful little game is over..."
PRINT TAB(5); "Right:"; right
PRINT TAB(5); "Wrong"; wrong
IF wrong = 2 THEN PRINT "Loser..."
IF right = 2 THEN PRINT "Awesome..."
END SUB

SUB myTrivia (rAns$, jQuestion$, jAns1$, jAns2$, jAns3$, jAns4$)

' This outputs the variables passed to this SUB
COLOR INT(RND * 15) + 1
PRINT jQuestion$
PRINT TAB(3); "Correct Answers:"; right
PRINT TAB(3); "Wrong Answers:"; wrong
PRINT "<A> "; jAns1$
PRINT "<B> "; jAns2$
PRINT "<C> "; jAns3$
PRINT "<D> "; jAns4$

' loop until a, b, c, or d is pressed
DO UNTIL UCASE$(press$) = "A" OR UCASE$(press$) = "B" OR UCASE$(press$) = "C" OR UCASE$(press$) = "D"
press$ = INKEY$
LOOP
' calculate if this is right or wrong
IF UCASE$(rAns$) = UCASE$(press$) THEN
   right = right + 1
PRINT "Correct!"
ELSE
   wrong = wrong + 1
PRINT "And I thought you knew hockey..."
END IF

press$ = ""' so I can re-use this string variable
PRINT "Press any key to continue..."
DO WHILE press$ = ""
press$ = INKEY$
LOOP
CLS
END SUB

