View Single Post
Old 08-14-2002, 04:33 PM   #1 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
the endless loop loop loop loop loop loop ...

just thought id share a pretty basic thing that i came up with while getting stuck in many-a-endless loop.

Code:
int goneToFar = 0;
boolean mainLoopSetter = true;

while(mainLoopSetter || goneToFar > 100)
{
 //do whatever to set mainLoop false
goneToFar++; //this added to exit out if the other doesn't get set
}
its pretty simple, and i've only used it once, but not only does it stop from crashing your computer and very quickly running out of memory but it may even force you to see the problem for the loop before you even test it...


--EDIT--
oops.. changed to OR and greater then
--EDIT--
__________________
-- bloomberg.
abc123 is offline   Reply With Quote