For : Next
Syntax
For <variable> = <expression1> To <expression2> [Step <constant>] ... Next [<variable>]
Description
The 'For : Next' function is used to cause a loop within a programme within given parameters. At each loop the <variable> is increased by a factor of 1, (or of the "Step value" if a Step value is specified), when the <variable> value equals the <expression2> loop stop.
Example 1 :
For k = 0 To 10 ... Next In this example, the programme will loop 11, time (0 to 10), then quit.Example 2 :
a = 2 b = 3 For k = a+2 To b+7 Step 2 ... Next kHere, the programme will loop 4 times before quitting, (k is increased by a value of 2 at each loop, so the k value is: 4-6-8-10). The "k" after the "Next" indicates that "Next" is ending the "For k" loop. If another variable, is used the compiler will generate an error. It is useful when nesting some "For/Next" expressions.
Example 3 :
For x=0 To 320 For y=0 To 200 Plot(x,y) Next y Next x