Skipping within a For Loop
#18
I know. I can't say I'm a fan of _CONTINUE, either.

To the example James posted I'd say eat that pasta before it gets cold!

Of course this would be perfectly acceptable, right Steve?

Code: (Select All)
For i = 1 To 10
    If i <> 5 Then Print i; 'print i unless i =5
    On i GOSUB do1, do2, do3 'keep the loop visually brief by going to other lines
Next
End
do1:
Print "!";
RETURN
do2:
Print "#";
RETURN
do3:
Print "@";
RETURN

In the old days, before SELECT CASE, something like this would be an alternative to use IF/THEN/ELSE

I have to admit in some code of mine dated back to 2000 I've found the classic...

Code: (Select All)
FOR  I = 1 TO 10
IF I = 2 OR I = 8 THEN GOTO BYPASSI
PRINT I
BYPASSI:
NEXT

I coded all caps and no indentation or remarks, back then. Anyway, I wonder if the above example is the way the compiler translates this to the C/C++ output or if it encases the snippet into the C/C++ equivalent of:

Code: (Select All)
FOR  I = 1 to 10
IF I = 2 OR I = 8 THEN
ELSE
PRINT I
END IF
NEXT

Pete
Reply


Messages In This Thread
Skipping within a For Loop - by Dimster - 10-23-2022, 03:38 PM
RE: Skipping within a For Loop - by Pete - 10-23-2022, 03:46 PM
RE: Skipping within a For Loop - by SMcNeill - 10-23-2022, 03:49 PM
RE: Skipping within a For Loop - by SMcNeill - 10-23-2022, 03:52 PM
RE: Skipping within a For Loop - by PhilOfPerth - 10-23-2022, 11:03 PM
RE: Skipping within a For Loop - by a740g - 10-23-2022, 03:54 PM
RE: Skipping within a For Loop - by SMcNeill - 10-23-2022, 03:56 PM
RE: Skipping within a For Loop - by Pete - 10-23-2022, 04:15 PM
RE: Skipping within a For Loop - by Dimster - 10-23-2022, 04:48 PM
RE: Skipping within a For Loop - by Pete - 10-23-2022, 04:58 PM
RE: Skipping within a For Loop - by OldMoses - 10-23-2022, 06:08 PM
RE: Skipping within a For Loop - by Pete - 10-23-2022, 08:30 PM
RE: Skipping within a For Loop - by Dimster - 10-23-2022, 10:02 PM
RE: Skipping within a For Loop - by Pete - 10-23-2022, 11:36 PM
RE: Skipping within a For Loop - by OldMoses - 10-23-2022, 11:48 PM
RE: Skipping within a For Loop - by Pete - 10-24-2022, 12:11 AM
RE: Skipping within a For Loop - by mnrvovrfc - 10-24-2022, 11:18 AM
RE: Skipping within a For Loop - by Dimster - 10-24-2022, 03:52 PM
RE: Skipping within a For Loop - by mnrvovrfc - 10-24-2022, 07:16 PM
RE: Skipping within a For Loop - by Pete - 10-24-2022, 04:46 PM
RE: Skipping within a For Loop - by Dimster - 10-24-2022, 06:03 PM
RE: Skipping within a For Loop - by CharlieJV - 10-24-2022, 06:19 PM
RE: Skipping within a For Loop - by Pete - 10-24-2022, 06:27 PM
RE: Skipping within a For Loop - by mnrvovrfc - 10-24-2022, 07:11 PM
RE: Skipping within a For Loop - by Pete - 10-24-2022, 08:44 PM



Users browsing this thread: 18 Guest(s)