home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
576-600
/
apd593
/
n_question_displayer.amos
/
n_question_displayer.amosSourceCode
Wrap
AMOS Source Code
|
1993-03-31
|
4KB
|
173 lines
'
'********************************
'
' Quiz question displayer
' -----------------------
'
' By Malcolm Lavery 1993
'
'********************************
'
'********************************
'When this program askes you a
'question,it will never ask you
'it again.
'Unless you re-run the program!
'
' Press 1 to 3 to answer!
'********************************
'
Screen Open 0,320,200,32,Lowres
Curs Off : Cls 2 : Flash Off : Pen 1 : Paper 2
Palette $0,$FFF,$5
'
'********************************
' Open random file from disk
'********************************
'
Open Random 1,"df1:Quiz.Data"
'
'********************************
'Set sizes for each of the fields
'********************************
'
Field 1,160 As Q$,40 As A1$,40 As A2$,40 As A3$
'
' Q$=Question (160 characters)
'
' A1$ \
' A2$ |=The three answers (40 characters each)
' A3$ /
'
'********************************
' Set variables
'********************************
'
NUMBER=7 : Rem ***** Number of questions entered in editor!...
SCORE=0 : Rem ***** reset score to zero...
_ASKED=0 : Rem ***** number of questions asked so far..
Dim A$(3),F(3),_DONE(NUMBER) : Rem set size of array for choices...
'
'********************************
' Make variables global
'********************************
'
Global NUMBER,A$(),F(),_DONE(),SCORE,Q$,A1$,A2$,A3$,_ASKED
'
'********************************
' Set up screen display
'********************************
'
Locate 15,0
Print "SCORE "+Mid$(Str$(SCORE),2)+" "
'
'*****************************************************************
' MAIN LOOP
'*****************************************************************
'
Do
'
_GET_QUESTION
'
Loop
'
'*****************************************************************
'
'
Procedure _GET_QUESTION
'
'**************************
' Get random question
'**************************
'
QUESTION=Rnd(NUMBER-1)+1
'
'**************************
' Check if already asked
'**************************
'
If _DONE(QUESTION)=1
Pop Proc
End If
'
'******************************
'Get question/answers fron file
'******************************
'
Get 1,QUESTION
_DONE(QUESTION)=1
'
'******************************
' Place answers in array
'******************************
'
A$(1)=A1$ : A$(2)=A2$ : A$(3)=A3$
F(1)=0 : F(2)=0 : F(3)=1
'
'******************************
' Jumble the answers up
'******************************
'
For A=1 To 10
X=Rnd(1)+1
Swap A$(X),A$(3)
Swap F(X),F(3)
Next A
'
'******************************
' Display question & answers
'******************************
'
Locate 0,2
Print "Q:";Q$
Print "A1:";A$(1)
Print
Print "A2:";A$(2)
Print
Print "A3:";A$(3)
Print
'
'******************************
' Enter your choice
'******************************
'
Print "Enter choice (1,2 or 3) :";
Repeat
A$=Upper$(Inkey$)
Until A$="1" or A$="2" or A$="3"
Print
'
'******************************
' Check if right or wrong
'******************************
'
A=Val(A$)
Print
If F(A)=1
Print "Correct,Well done!."
Inc SCORE
Locate 15,0
Print "SCORE "+Mid$(Str$(SCORE),2)+" "
Else
Print "Sorry,Wrong!."
End If
'
Wait 100
'
'*****************************************
' Asked all the questions
'*****************************************
'
Inc _ASKED
If _ASKED=NUMBER
Close 1
Locate 0,20
Print "You got "+Mid$(Str$(SCORE),2)+" right out of "+Mid$(Str$(_ASKED),2)+" questions."
Wait 200
End
End If
'
Locate 0,0
Cls 2,0,10 To 320,200
'
End Proc