Is there a way to limit the number of iterations in a while loop? Right now I am cleaning up the code, and for now if I make a mistake, the loop keeps going forever. I'd like to be able to limit the number of times it will run through while I am working on it. Is that possible?
As an alternative to a manual check of the iterator, as proposed by Kuba, you could refactor to use
NestWhile by converting your body and test to functions without parameters:
n = 1; NestWhile[(Print[n]; n++) &, , (n > 0) &, 1, 7];
n > 0 would normally result in an infinite loop, but here it is limited to