Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Break from Nested Loops
#1
Is there an elegant way to break from nested loops to 'outer' loop (or even to top-level loop if multiply nested). I know you could use goto statement but I try to avoid as much as possible in my program because it feels messy.
I am okay if there is no better answer Big Grin
Thanks,
S

Macro Macro132
Code:
Copy      Help
ARRAY(str) arr1 = "1[]2[]3[]4[]5[]6"
ARRAY(str) arr2 = "A[]B[]C[]D[]E"

int r
for _i 0 arr1.len
,;out F"{_i}: '{arr1[_i]}'"
,for r 0 arr2.len
,,if arr2[r] = "C"
,,,break;;want to break out of outer loop here as well instead of using goto statement
,,,;goto g1
,,out F"{_i}: '{arr1[_i]}' : {r}: {arr2[r]}"
,out "---------"

;g1


Messages In This Thread
Break from Nested Loops - by stupomer - 10-02-2019, 07:32 PM
RE: Break from Nested Loops - by Start_Learning - 10-06-2019, 08:54 PM
RE: Break from Nested Loops - by stupomer - 10-06-2019, 09:08 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)