PDA

View Full Version : Is there a penalty for breaking early out of a For Loop with a Goto Statement?



khufumen
- 14th October 2016, 17:53
I have a For Loop nested inside another For Loop and there will be times that I want to break out of the inner loop and outer loop before either of them finish.
Can one do this with a GoTo without causing a value to remain on the stack or blow up my program later on?

HenrikOlsson
- 14th October 2016, 18:24
With a GOTO, yes I don't see a problem with that. Another option might be to "manually" set the index variable so that the loop ends when the current iterations is finished.

/Henrik.

pedja089
- 14th October 2016, 20:20
You can also use EXIT.

khufumen
- 14th October 2016, 23:07
Thank you for your help.
I wasn't aware of the Exit command.
Answers my question.

You guys really rock in terms of your support and patience for us newbies!