Re: How can I STOP a cursed recursion?
- Posted by ChrisBurch2 <crylex at freeuk.co.uk> Jun 19, 2006
- 557 views
Hi Sorry, stuff got a bit garbled. I tend to use functions, because its easier to break out of a function than a procedure. This is the way I do it Generally you need a global indicator variable. This tells the loop, and all previous loop iterations to stop. An infinite loop within the procedure
integer break_free --this is global to the program break_free = 0 procedure foo() while 1 do if break_free = 1 then exit end if --do stuff --are conditions met to exit loop if conditions met then break_free = 1 end if foo() end while end procedure
Note the position of loop testing, and setting the global break free variable - if you've recursed (?) 10 times, then you exit the loop 10 times You must also reset break_free to 0 immediately after calling foo() for the first time Chris