PDA

View Full Version : Breaking out of for loops



Kamikaze47
- 14th March 2008, 17:42
Just a quickie. Is it safe to break out of a subroutine when in the middle of a for loop? Or will stacks and things get messed up?

Example of what i'm talking about:


subroutine:
FOR n=0 TO 100
IF n=50 then RETURN
NEXT n
RETURN

Melanie
- 14th March 2008, 17:57
That is OK.

For-Next loops do not use stack space.

Kamikaze47
- 14th March 2008, 18:00
Cool. Thanks Melanie.

rwskinner
- 17th March 2008, 00:49
Would a While/Wend be more appropriate?