Im creating a Quiz Program. Can someone suggest a way to generate the questions at random, and them store them somewhere so there not asked againg during the program. Thanks for your help.
Hello QBGL,
what sort of quiz that will be?
You see, there no way to BASIC "speak" smth of it's own.
I can suggest:
YOU create list of questions (in a file, a question per line)
read it into string array (using LINE INPUT #1)
then generate random number (say N) and show Nth element of array.
You can store N you got (and check against it) so not to ask same question twice.
DATA What is your favorite food?, What is your age?
DATA What is your favorite color?, What is your heighth?
DATA When were you born?, What color is your hair?
DATA Do you like turnips?, What grade are you in?
DATA What is you occupation?, Do you like to fish?
ect...
DATA What is your favorite food?, What is your age?
DATA What is your favorite color?, What is your heighth?
DATA When were you born?, What color is your hair?
DATA Do you like turnips?, What grade are you in?
DATA What is you occupation?, Do you like to fish?
ect...
I noticed that you wanted to store the question, so that they would not get it again. This will do that:
DIM question$(20), catch(20), answer$(20)
ON ERROR GOTO skip:
FOR I = LBOUND(question$) TO UBOUND(question$)
READ question$(I)
NEXT I
skip:
RANDOMIZE TIMER
number = INT(RND * I) + LBOUND(question$)0
IF catch(number) = 1 THEN GOTO skip:
catch(number) = 1
PRINT question$(number)
INPUT answer$(number)
DATA What is your favorite food?, What is your age?
DATA What is your favorite color?, What is your heighth?
DATA When were you born?, What color is your hair?
DATA Do you like turnips?, What grade are you in?
DATA What is you occupation?, Do you like to fish?
ect...
DO
holding$ = keypress
IF questionypos = 22 THEN
questionypos = 4
questionxpos = 33
DO: LOOP UNTIL keypress <> ""
clearquestionbox
END IF
question3 = question3 + 1
question5% = question5% + 1
question4 = MID$(question, question5%, 1)
questionxpos = questionxpos + 1
IF question3 > 37 AND question3 < 45 AND question4 = " " THEN
questionypos = questionypos + 1
questionxpos = 33
question3 = 0
END IF
IF INKEY$ <> "" THEN
ELSE
FOR i& = 1 TO 55000
NEXT i&
END IF
LOCATE questionypos, questionxpos
PRINT question4
LOOP UNTIL question5% = question2
here's a small look at what each string/integer is.
question: this holds the question.
question2: this holds the length of the question.
question3: this holds the information on which letter the sub is working on.
question4: this will hold the actual letter. in the end of the sub, this will be printed, then the next letter after this, and so on.
question5: same as question3, except that this will permanently show the info: question3 will revert back to 0 once it gets too big. this will make certain that the information will never go over the screen.
i%: this will delay the computer for about 1/10th of a second. Maybe less if your computer is slower.
questionypos: this will tell you which column to put the letter. it will revert back to zero when it reaches the bottom of the text.
questionxpos: this will tell you which row to put the letter. it will revert back to 33 when it reaches the end of the screen.
I don't have the time to give a complete explanation, and i'm sure some of the more experienced guys will scour over my coding to find bugs and humiliate me. hint: *sarcasm*
This is in now way for you to just copy it and paste it. I would prefer for you to take a look at it. break it down and find out how it works. i never had the time to comment it, so best of luck.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.