home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / 576-600 / apd593 / n_question_displayer.amos / n_question_displayer.amosSourceCode
AMOS Source Code  |  1993-03-31  |  4KB  |  173 lines

  1. '
  2. '********************************
  3. '  
  4. '     Quiz question displayer
  5. '     -----------------------
  6. '
  7. '     By Malcolm Lavery 1993 
  8. '
  9. '********************************
  10. '
  11. '********************************
  12. 'When this program askes you a 
  13. 'question,it will never ask you  
  14. 'it again. 
  15. 'Unless you re-run the program!
  16. '
  17. '    Press 1 to 3 to answer! 
  18. '********************************
  19. '
  20. Screen Open 0,320,200,32,Lowres
  21. Curs Off : Cls 2 : Flash Off : Pen 1 : Paper 2
  22. Palette $0,$FFF,$5
  23. '
  24. '********************************
  25. '  Open random file from disk
  26. '********************************
  27. '
  28. Open Random 1,"df1:Quiz.Data"
  29. '
  30. '********************************
  31. 'Set sizes for each of the fields
  32. '********************************
  33. '
  34. Field 1,160 As Q$,40 As A1$,40 As A2$,40 As A3$
  35. '
  36. '  Q$=Question (160 characters)  
  37. '
  38. '  A1$ \ 
  39. '  A2$  |=The three answers (40 characters each) 
  40. '  A3$ / 
  41. '
  42. '********************************
  43. '        Set variables 
  44. '********************************
  45. '
  46. NUMBER=7 : Rem ***** Number of questions entered in editor!...
  47. SCORE=0 : Rem ***** reset score to zero... 
  48. _ASKED=0 : Rem ***** number of questions asked so far.. 
  49. Dim A$(3),F(3),_DONE(NUMBER) : Rem set size of array for choices... 
  50. '
  51. '********************************
  52. '     Make variables global
  53. '********************************
  54. '
  55. Global NUMBER,A$(),F(),_DONE(),SCORE,Q$,A1$,A2$,A3$,_ASKED
  56. '
  57. '********************************
  58. '    Set up screen display 
  59. '********************************
  60. '
  61. Locate 15,0
  62. Print "SCORE "+Mid$(Str$(SCORE),2)+" "
  63. '
  64. '***************************************************************** 
  65. '                          MAIN LOOP 
  66. '***************************************************************** 
  67. '
  68. Do 
  69.    '
  70.    _GET_QUESTION
  71.    '
  72. Loop 
  73. '
  74. '***************************************************************** 
  75. '
  76. '
  77. Procedure _GET_QUESTION
  78.    '
  79.    '**************************
  80.    '   Get random question
  81.    '**************************
  82.    '
  83.    QUESTION=Rnd(NUMBER-1)+1
  84.    '
  85.    '**************************
  86.    '  Check if already asked
  87.    '**************************
  88.    '
  89.    If _DONE(QUESTION)=1
  90.       Pop Proc
  91.    End If 
  92.    '
  93.    '******************************
  94.    'Get question/answers fron file
  95.    '******************************
  96.    '
  97.    Get 1,QUESTION
  98.    _DONE(QUESTION)=1
  99.    '
  100.    '******************************
  101.    '   Place answers in array 
  102.    '******************************
  103.    '
  104.    A$(1)=A1$ : A$(2)=A2$ : A$(3)=A3$
  105.    F(1)=0 : F(2)=0 : F(3)=1
  106.    '
  107.    '******************************
  108.    '   Jumble the answers up    
  109.    '******************************
  110.    '
  111.    For A=1 To 10
  112.       X=Rnd(1)+1
  113.       Swap A$(X),A$(3)
  114.       Swap F(X),F(3)
  115.    Next A
  116.    '
  117.    '******************************
  118.    '  Display question & answers
  119.    '******************************
  120.    '
  121.    Locate 0,2
  122.    Print "Q:";Q$
  123.    Print "A1:";A$(1)
  124.    Print 
  125.    Print "A2:";A$(2)
  126.    Print 
  127.    Print "A3:";A$(3)
  128.    Print 
  129.    '
  130.    '******************************
  131.    '      Enter your choice 
  132.    '******************************
  133.    '
  134.    Print "Enter choice (1,2 or 3) :";
  135.    Repeat 
  136.       A$=Upper$(Inkey$)
  137.    Until A$="1" or A$="2" or A$="3"
  138.    Print 
  139.    '
  140.    '******************************
  141.    '   Check if right or wrong
  142.    '******************************
  143.    '
  144.    A=Val(A$)
  145.    Print 
  146.    If F(A)=1
  147.       Print "Correct,Well done!."
  148.       Inc SCORE
  149.       Locate 15,0
  150.       Print "SCORE "+Mid$(Str$(SCORE),2)+" "
  151.    Else 
  152.       Print "Sorry,Wrong!."
  153.    End If 
  154.    '
  155.    Wait 100
  156.    '
  157.    '***************************************** 
  158.    '        Asked all the questions 
  159.    '***************************************** 
  160.    '
  161.    Inc _ASKED
  162.    If _ASKED=NUMBER
  163.       Close 1
  164.       Locate 0,20
  165.       Print "You got "+Mid$(Str$(SCORE),2)+" right out of "+Mid$(Str$(_ASKED),2)+" questions."
  166.       Wait 200
  167.       End 
  168.    End If 
  169.    '
  170.    Locate 0,0
  171.    Cls 2,0,10 To 320,200
  172.    '
  173. End Proc