# HG changeset patch # User Laurens Holst # Date 1696443242 -7200 # Wed Oct 04 20:14:02 2023 +0200 # Node ID 7c60e30c656cd53ff29a1b0a42afb8afa952560f # Parent 57cb503abd958a734ad35975cc3c326f878c00bd basic_tips_tricks: Improve for-next-goto tip description. diff --git a/articles/basic_tips_tricks.php b/articles/basic_tips_tricks.php --- a/articles/basic_tips_tricks.php +++ b/articles/basic_tips_tricks.php @@ -26,7 +26,7 @@

Jumping out of a FOR loop without increasing the FOR/NEXT stack

-

When you have a FOR/NEXT loop, Basic will place a counter on an internal stack. This counter is removed when the loop ends, however if you jump out of a loop like in the following example, the counter will never be removed. If you repeat this often enough, the stack will overflow and Basic will quit the program with an error:

+

When you have a FOR/NEXT loop, Basic will place the FOR location on its internal stack, so that NEXT knows where the loop begins. This location is removed from the stack when the loop ends, however if you jump out of a loop with GOTO like in the following example, the FOR location will never be removed. If you repeat this often enough, the stack will overflow and Basic will quit the program with an error:

10 FOR I=0 TO 1000
 20 IF STRIG(0) THEN GOTO 40