FOR...NEXT
FOR variable = startExpr TO endExpr {STEP stepExpr}
[CONTINUE]
[BREAK]
[EXIT FOR]
{ statement }
ELSE
{ statement }
END FOR | NEXT {variable}
Loop from startExpr to endExpr, incrementing by stepExpr. If stepExpr is left off, it is assumed to be 1. BREAK leaves the loop immediately, while CONTINUE jumps to the top of the loop for the next value.
Here is an example of a loop printing the numbers between 1 and 10, inclusive:
' loop from 1 to 10
FOR i = 1 TO 10
PRINT i
NEXT
If the loop is not exited via the BREAK statement, the ELSE clause will execute.
' loop through an array, looking for a value
FOR i = 1 to LENGTH( list )
IF list[i] = someValue THEN
PRINT "Found it!"
BREAK
END IF
ELSE
PRINT "Didn't find it"
END FOR