Quote from Joerg on June 16, 2026, 5:37 pmHi everyone at the forum,
if I want to exit a script within a loop, like "Loop 1 100 [counter]", what would be the correct way to do this? Can I use "ExitLoop" first and then "Return"? Or is it better to use a "While" loop instead? My thought is, that a loop with defined start- and end-values, needs to be exited cleanly to avoid a stack overflow.
Thanks very much for your help :-)
Kind regards,
Joerg
Hi everyone at the forum,
if I want to exit a script within a loop, like "Loop 1 100 [counter]", what would be the correct way to do this? Can I use "ExitLoop" first and then "Return"? Or is it better to use a "While" loop instead? My thought is, that a loop with defined start- and end-values, needs to be exited cleanly to avoid a stack overflow.
Thanks very much for your help :-)
Kind regards,
Joerg

Quote from luishp on June 17, 2026, 10:59 am@joerg use ExitLoop to leave the current Loop ... EndLoop block. After that, execution continues after EndLoop. You only need Return as well if you want to stop the whole script/subroutine, not just the loop.
@joerg use ExitLoop to leave the current Loop ... EndLoop block. After that, execution continues after EndLoop. You only need Return as well if you want to stop the whole script/subroutine, not just the loop.
Quote from Joerg on June 17, 2026, 11:31 amThanks Luis! But after leaving the loop, I also want to exit the whole script. I guess, this can only be done by checking, if the loop is incomplete, right?
Kind regards,
Joerg
Thanks Luis! But after leaving the loop, I also want to exit the whole script. I guess, this can only be done by checking, if the loop is incomplete, right?
Kind regards,
Joerg

Quote from luishp on June 17, 2026, 12:05 pmHi Joerg,
you don’t need to check whether the loop completed or not.
If your goal is leave the loop and stop the whole script immediately, you can simply use Return directly from inside the loop.Example:
Loop 1 100 [counter] If [counter] == 25 Return EndIf ... other commands ... EndLoop ... this code will never execute if Return was triggered ...
Returnexits the current script/subroutine immediately — it does not needExitLoopbeforehand.Use:
ExitLoop→ leave the loop but continue executing the script afterEndLoopReturn→ leave the entire script immediately (and therefore also leave any active loop)So this is unnecessary:
ExitLoop Returnbecause
Returnalready ends execution.The only time you would set a flag and check afterward is if you intentionally want:
ExitLoop ... If [abort] == "true" Return EndIfthat pattern is useful when cleanup code should still run after the loop.
Kind regards,
Hi Joerg,
you don’t need to check whether the loop completed or not.
If your goal is leave the loop and stop the whole script immediately, you can simply use Return directly from inside the loop.
Example:
Loop 1 100 [counter]
If [counter] == 25
Return
EndIf
... other commands ...
EndLoop
... this code will never execute if Return was triggered ...
Return exits the current script/subroutine immediately — it does not need ExitLoop beforehand.
Use:
ExitLoop → leave the loop but continue executing the script after EndLoopReturn → leave the entire script immediately (and therefore also leave any active loop)So this is unnecessary:
ExitLoop
Return
because Return already ends execution.
The only time you would set a flag and check afterward is if you intentionally want:
ExitLoop ... If [abort] == "true" Return EndIf
that pattern is useful when cleanup code should still run after the loop.
Kind regards,
Quote from Joerg on June 18, 2026, 1:35 pmHi Luis,
thanks very much for your help! I didn't know, that it is possible to exit from a loop this way :-)
Kind regards,
Joerg
Hi Luis,
thanks very much for your help! I didn't know, that it is possible to exit from a loop this way :-)
Kind regards,
Joerg
Quote from capacitypastel on October 2, 2026, 5:30 amQuote from Joerg driving directions on June 18, 2026, 1:35 pmHi Luis,
thanks very much for your help! I didn't know, that it is possible to exit from a loop this way :-)
Kind regards,
JoergThis error is almost certainly from a typo in the neo-row or neo-col classes you just edited. You should check all those container class names for correct spelling and valid numbers (1-12), then do a Clean & Rebuild and test again.
Quote from Joerg driving directions on June 18, 2026, 1:35 pmHi Luis,
thanks very much for your help! I didn't know, that it is possible to exit from a loop this way :-)
Kind regards,
Joerg
This error is almost certainly from a typo in the neo-row or neo-col classes you just edited. You should check all those container class names for correct spelling and valid numbers (1-12), then do a Clean & Rebuild and test again.
Quote from isaacwalker on October 16, 2026, 9:45 amQuote from Joerg slope game on June 16, 2026, 5:37 pmHi everyone at the forum,
if I want to exit a script within a loop, like "Loop 1 100 [counter]", what would be the correct way to do this? Can I use "ExitLoop" first and then "Return"? Or is it better to use a "While" loop instead? My thought is, that a loop with defined start- and end-values, needs to be exited cleanly to avoid a stack overflow.
Thanks very much for your help :-)
Kind regards,
JoergI think the best approach depends on the scripting language, since loop exit commands behave differently. Which scripting tool are you using?
Quote from Joerg slope game on June 16, 2026, 5:37 pmHi everyone at the forum,
if I want to exit a script within a loop, like "Loop 1 100 [counter]", what would be the correct way to do this? Can I use "ExitLoop" first and then "Return"? Or is it better to use a "While" loop instead? My thought is, that a loop with defined start- and end-values, needs to be exited cleanly to avoid a stack overflow.
Thanks very much for your help :-)
Kind regards,
Joerg
I think the best approach depends on the scripting language, since loop exit commands behave differently. Which scripting tool are you using?