News:

  • September 22, 2026, 04:25:02 AM

Login with username, password and session length

Author Topic: Jump inside FOR/NEXT Loop  (Read 10292 times)

Bolt

  • Hero Member
  • *****
  • Posts: 598
Jump inside FOR/NEXT Loop
« on: June 30, 2023, 05:45:03 PM »
Is there a way to "jump" forward inside a FOR/NEXT loop? Similar to the CONTINUE instruction, but not entirely to the end. Rather, to a defined point in the loop.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Jump inside FOR/NEXT Loop
« Reply #1 on: June 30, 2023, 10:59:58 PM »
Maybe roll up everything you want to skip in a subroutine and don't call it on those passes?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Jump inside FOR/NEXT Loop
« Reply #2 on: July 01, 2023, 10:11:55 AM »
GOTO/LABEL  Spaghetti code at its finest.

Just make sure you don't GOTO a LABEL that is out of the loop (stage, code block, etc.)

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Jump inside FOR/NEXT Loop
« Reply #3 on: July 03, 2023, 10:02:45 AM »
GOTO/LABEL  Spaghetti code at its finest.

Just make sure you don't GOTO a LABEL that is out of the loop (stage, code block, etc.)

Perfect. The help file only showed BREAK, CONTINUE, REPEAT, UNTIL, WEND, WHILE as my options for a FOR Index Loop. GOTO, LABEL however, do link back to FOR, NEXT. I don't think my code will get too spaghetti like with a simple addition to skip partial loop code for certain index ranges.

Thanks!