Escaping Do Loops Inside Do Loops
I am making a number guessing game, in Liberty BASIC, and the only way i can think of having a menu and then the main game start without using GOTO is to do a multi loop loop,
example
Do
*user selects level*
if level one
Do
*level one code
Loop
if level Two
Do
*level 2*
Loop
and so on
My problem is excaping the main program loop in order to end the program, i think a way i could do this is below the IF statements to do a variable check, so if the inputed number = the random number, then exit the loop,
anyone got any better way?
Here is the whole thing and i have to have those DO while, its the way LB works
guessOne = int(rnd(1)*10)
guessTwo = int(rnd(1)*50)
guessThree = int(rnd(1)*100)
[start]
Print "HI/LO"
Do while 1 = 1
Input "Select difficulty Level (1/2/3): "; levSel
if levSel = 1 then Do while 1 =1
Input "Enter Number (1/50): "; userOne
if userOne = guessOne then exit do
if userOne < guessOne then print "Too Low"
if userOne > guessOne then print "Too High"
loop
if userOne = guessOne then exit DO
if levSel = 2 then Do while 1 = 1
Input "Enter Number (1/100): "; userTwo
if userTwo = guessTwo then exit do
if userTwo < guessTwo then print "Too Low"
if userTwo > guessTwo then print "Too High"
loop
if userTwo = guessTwo then exit DO
if levSel = 3 then Do while 1 = 1
Input "Enter Number (1/10): "; userThree
if userThree = guessThree then exit do
if userThree < guessThree then print "Too Low"
if userThree > guessThree then print "Too High"
loop
if userThree = guessThree then exit DO
loop
print "Congratulations you won"
end
if userOne = guessOne then exit do if userOne < guessOne then print "Too Low" if userOne > guessOne then print "Too High" Does it actually print out "Too Low" or "Too High"? I don't know anything about basic, but I get the feeling that your if statements are nested inside the first one. I dont see any form of endIf.