Quote: "Randomize timer()...is that why in my other project I end up with the same "random" question three times in a row? If I throw that in it will fix it?"
Yeah, it guarantees that it will pick more random numbers because you use TIMER() as the seed. When you run it again the TIMER() will use a different seed. Without using RANDOMIZE it's possible to pick the same "random" numbers every time the program is ran.
Quote: "GOTO seems to be frowned upon, so I was just wondering if that was how to do it. It's probably way more simple."
Yes, lets avoid GOTO. If you absolutely have to use GOTO make it GOSUB instead because you can use RETURN to go back to the line just after the GOSUB. I'm glad you didn't have either one in your code snips.
Quote: "Once data is read, is it considered "used" and so DBPro just knows to move to the next data statement?"
Yes. Darkbasic knows which DATA statement was last read and it is possible to go back to previously read DATA statements using the RESTORE command. RESTORE by itself starts at the first DATA statement or if you use a label it'll go to the first DATA statement after the label (the same kind of labels used in GOTO and GOSUB commands).
randomize timer()
dim masc$(4)
dim fem$(4)
` Read feminine data first
restore Fem
for N=0 to 4
read fem$(N)
NEXT N
` Read masculine data next
restore Masc
for N=0 to 4
read masc$(N)
NEXT N
do
m$=masc$(rnd(4))
f$=fem$(rnd(4))
q=rnd(1)
cls
if q=0 then print m$; x$="m"
if q=1 then print f$; x$="f"
input "Masculine or feminine? (M/F): ";answer$
if answer$=x$ then print "Great!"
if answer$<>x$ then print "Nope!"
wait 2000
LOOP
` Label for masculine words
Masc:
data "mapa","suelo","borrador","escritorio","pupitre"
` Label for feminine words
Fem:
data "pluma","gorra","ventana","bandera","madre"
Quote: "Getting there...I get a wrong answer every time and a 0 appears after the question."
The zero appears because you use a semicolon after the PRINT statement. Change it to a colon and the zero goes away. The wrong answer every time may be because your caps lock may have been on. Because you check if answer$="m" or answer$="f" if the user typed "M" or "F" it would be considered a wrong answer. To make sure the user types either a "m" or "f" in lower case use the LOWER$() command to convert the string to lower case. Also there's no need to check the answer$ twice because you can use ELSE like this:
` Make sure the answer is lower case
answer$=lower$(answer$)
` Check if answer$ equals x$
if answer$=x$
` Do the following if answer$ does equal x$
print "Great!"
else
` If answer$ does not equal x$ do the following
print "Nope!"
endif
The ENDIF above closes the IF/THEN condition.
Or if you prefer the IF/THEN on one line:
` Make sure the answer is lower case
answer$=lower$(answer$)
if answer$=x$ then print "Great!" else print "Nope!"
Here's all the code modified:
randomize timer()
dim masc$(4)
dim fem$(4)
for N=0 to 4
read masc$(N)
NEXT N
for N=0 to 4
read fem$(N)
NEXT N
do
m$=masc$(rnd(4))
f$=fem$(rnd(4))
q=rnd(1)
cls
if q=0 then print m$: x$="m"
if q=1 then print f$: x$="f"
input "Masculine or feminine? (M/F): ";answer$
` Make sure the answer is lower case
answer$=lower$(answer$)
` Check if answer$ equals x$
if answer$=x$ then print "Great!" else print "Nope!"
wait 2000
LOOP
data "mapa","suelo","borrador","escritorio","pupitre"
data "pluma","gorra","ventana","bandera","madre"