
-----------------------------------
manwinder
Tue Jun 12, 2012 3:24 pm

nested loop help
-----------------------------------
i was having problems with this code, this code is just a example of what my code does, so don't try to change the way i am doing it in.

[code]for gamecounter : 1 .. numofplay
   loop
put"1"
exit when 1=1
    end loop
end for
[/code]

the problem i am having is the for loop exits when i want only the normal loop to exit, like i want it to move to the next gamecounter and loop again. how o i get this to only leave the loop and not the for loop. also i tried using a for loop inside a for loop but the only way that can work is if i can change the values it goes to, so like this( i already tried it, it don't work):
[code]for gamecounter : 1 .. numofplay
   for temp: 1 .. infinites
put"1"
infintie:= infinites+1
    end for
end for
[/code]

i need it to leave the loop inside when a boolean turns true

-----------------------------------
Tony
Tue Jun 12, 2012 3:31 pm

RE:nested loop help
-----------------------------------
the for-loop doesn't exit, it simply completes all of its iterations
[code]
for gamecounter : 1 .. numofplay 
   loop 
put"1" 
exit when 1=1 
    end loop
put "done with loop, still inside for-loop" 
end for 
[/code]

-----------------------------------
manwinder
Tue Jun 12, 2012 3:38 pm

RE:nested loop help
-----------------------------------
but the exit when, exits both loops, i need it to exit only the inside loo[

-----------------------------------
Tony
Tue Jun 12, 2012 6:50 pm

RE:nested loop help
-----------------------------------
no, it does not exit the outer loop. See [tdoc]exit[/tdoc]

-----------------------------------
manwinder
Tue Jun 12, 2012 6:52 pm

RE:nested loop help
-----------------------------------
i swear it does, i use this line

[code]exit when score = 0 or score = 10 or finished = true or GUI.ProcessEvent[/code]

i tried a loop within a loop, loopception or nested loop, it does exit the outer loop, i will update this tomorrow

-----------------------------------
copthesaint
Wed Jun 13, 2012 10:34 am

Re: nested loop help
-----------------------------------
You swear it does, really, because ive spent 5 years messing around with turing for fun and Its never done that once. 

var you : string := "Your a noob"
for i : 0 .. 0
loop
exit when "Your a noob" = you
put "if exit works you wont see this put statement"
end loop
put "If exit possibly did exit the for loop, you wouldnt see this message but you do, and your being an 455 for trying to argue this."
end for

Your arguing with someone who is in university for I dont know how long studing computer science.

-----------------------------------
Raknarg
Wed Jun 13, 2012 1:00 pm

RE:nested loop help
-----------------------------------
No need for rudeness here.

Alright, so it sounds like you have more code to show, it might make more sense if you do. It might just have to do with how you're writing it out.

-----------------------------------
manwinder
Wed Jun 13, 2012 3:36 pm

RE:nested loop help
-----------------------------------
haters gonna hate, i found out that one of the variables in the for loop was set to 1 and not what the user inputted

-----------------------------------
Raknarg
Wed Jun 13, 2012 8:19 pm

RE:nested loop help
-----------------------------------
Haha that was going to be my next thought :P
1 always equals 1
