10-24-2022, 08:44 PM
Loop jumping Pete style...
Stupid demo, but you'll get the point.
Anyway, it's a neat trick to enclose a DO/LOOP inside a WHILE/WEND.
Pete
Stupid demo, but you'll get the point.
Code: (Select All)
CLS
INPUT "Input 1 to jump one loop, 2 to jump 2, 3 to jump all: "; x
WHILE -1
DO
FOR i = -5 TO 5
IF i = x THEN
SELECT CASE x
CASE 1
EXIT FOR
CASE 2
EXIT DO
CASE 3
EXIT WHILE
CASE ELSE
PRINT "oops."
END
END SELECT
END IF
NEXT
IF x = 1 AND nextloop = 0 THEN PRINT "Next loop was exited. Press any key to redo.": nextloop = -1
IF LEN(INKEY$) THEN RUN
LOOP
IF doloop = 0 THEN PRINT "Do loop was exited. Press any key to redo": doloop = -1
IF LEN(INKEY$) THEN RUN
WEND
PRINT "While loop was exited. Press any key to redo"
SLEEP
RUN
Anyway, it's a neat trick to enclose a DO/LOOP inside a WHILE/WEND.
Pete