cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
TomWaltz
Participant

GDL Program flow question

In C++, there is a keyword CONTINUE, which is used inside a Do.. While or Repeat...Until loop. This keyword aborts the current loop, and starts over at the top.

I have not been able to find any equivalent in GDL. Is there some strange undocumented method I am missing?
Tom Waltz
2 Replies 2
Karl Ottenstein
Moderator Emeritus
TomWaltz wrote:
In C++, there is a keyword CONTINUE, which is used inside a Do.. While or Repeat...Until loop. This keyword aborts the current loop, and starts over at the top.

I have not been able to find any equivalent in GDL. Is there some strange undocumented method I am missing?
I think you meant to say "short circuits the current iteration of the enclosing loop", rather than "aborts the current loop"...

The GDL equivalent is ...(groan): GOTO.

More precisely, a GOTO to a label that is just before the NEXT statement.

Frequently it can be avoided using IF-THEN logic, but sometimes you have to introduce enough 'flag' variables/logic that the 'CONTINUE' approach looks appealing. For large loops, maintenance (future comprehension) becomes an issue ... so I suggest at least putting !! CONTINUE at the end of the GOTO line (or something like that) to remind you of the function of the GOTO. 😉

Karl

[Edited: typos]
Vote for Wish: Copy/Paste in 3D

AC 29 USA and earlier   •   hardware key   •   macOS Taho 26.1 MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
TomWaltz
Participant
Karl

you're right, I wanted to "short circuit" the current loop.

I was afraid you were going to say to use GOTO. Amazing how repulsive that feels!
Tom Waltz

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!