Posted: Sat Jan 13, 2007 5:52 pm Post subject: loop within a loop
okay well i need to make a loop within a loop but i need to be able for the loops to be different...somehow... as i am ending both loops with exit when and the one loop starts the line before the other... any suggestions? is there anyway i can make the loops distinct as in loop1 and loop2 and then exit loop1 when... exit loop2 when... that sorta of thing..... is this possible?
Sponsor Sponsor
neufelni
Posted: Sat Jan 13, 2007 6:36 pm Post subject: RE:loop within a loop
Yes this is possible. Here is an example program. It counts to 5 three times.
Turing:
var i :int:=0 var n :int:=0
loop loop
i +=1 put"Inner loop count: ", i
exitwhen i =5 endloop
n +=1
i :=0 put"Outer loop count: ", n
exitwhen n =3 endloop
So basically you just have an outer loop and an inner loop. The first exit when is for the inner loop and the second one is for the outer loop.
n00b.skillz
Posted: Sat Jan 13, 2007 7:25 pm Post subject: Re: loop within a loop
yea thanks alot i tried this before but it wasn't working and now i tried it again and it works... i must've keyed in something wrong by accident before... thanks for clearing this up!