09-12-2022, 05:33 PM
(09-12-2022, 05:06 PM)mnrvovrfc Wrote: This tip is good. I would add a comment on the line with "DO" that it will execute once on purpose. Either that, or "DO" or "LOOP" having "UNTIL 1" or "WHILE 0" after it and without the obligatory "EXIT DO" as the last statement controlled by the so-called loop.
While QB64 lacked "_CONTINUE" I learned a valuable tip on the Wiki page for "DO... LOOP" to emulate it. I had written a "preprocessor" having a few invented keywords, put in functionality like "_CONTINUE" that was translated into "IF condition THEN GOTO CONTINUE001" but it didn't work very well because it made a few assumptions. I abandoned my "preprocessor" after I discovered the tip on Wiki.
Yes, I actually do that. My method of defining these types of container loops is pretty simple...
DO ' Falx loop.
' foo
EXIT DO
LOOP
As you also discovered, this technique and block IF/THEN statements are effective ways to avoid GOTO statements. I find only a few rare occasions in my coding structure where GOTO is the better solution, and thankfully I can usually get away with a single instance in the entire program.
Thanks for the reply,
Pete