NEXT var
NEXT* var line-no

The NEXT statement is the partner of the FOR..TO statement. The variable specified by var is incremented (or decremented) by the STEP specified in the FOR..TO statement. If STEP is not specified, the variable will be incremented by one.

The NEXT* var line-no statement allows BASIC to exit early from a FOR..NEXT loop. BASIC will jump to the line specified by line-no, after performing a few housekeeping functions that allow it to exit the loop early. If the NEXT* command is not performed before exiting a loop prematurely, an error will occur.

Program Example.

00100 FOR I = 1 TO 100
00110  PRINT I
00120  IF I = 30 THEN NEXT* I 140
00130 NEXT I
00140 END

Try it

See also FOR