NEXT statement

Syntax

NEXT [variable]

Description

Use the NEXT statement to end a FOR...NEXT loop, causing the program to branch back to the FOR statement and execute the statements that follow it.

Each FOR statement must have exactly one corresponding NEXT statement.

variable is the name of the variable given as the index counter in the FOR statement. If the variable is not named, the most recently named index counter variable is assumed.

Example

FOR I=1 TO 10
   PRINT I:" ":
NEXT I
PRINT

This is the program output:

1 2 3 4 5 6 7 8 9 10