For...To...Step~Next
Repeats and executes the statements between the For statement and the Next statement.
For <Variable Name>=<Initial Value> To <Ending Value>[ Step <Increment>]
~
Next [<Variable Name>]
Parameters
<Variable Name>
|
Loop control counter variable name (integer).
|
<Variable Name>
|
The initial value of the loop control counter variable (integer).
|
<Ending Value>
|
The ending value of the loop control counter variable (integer).
|
<Increment>
|
The increment of the loop control counter variable (integer).
|
Return Value
None.
Description
The commands between For and Next are repeated and executed while changing from the initial value of the variable to the ending value.
The variable specified in the <Variable Name> calculates the number of times the loop is repeated with the For statement and the Next statement working in concert with each other.Thus, the variable specified in the <Variable Name> making up the loop for each For statement and Next statement set must be the same name.
The Step statement and <Increment> can be omitted, and when omitted, the Increment is set to +1.
The <Variable Name> after Next can be omitted.In this case it becomes equivalent to the <Variable Name> after For.
For each time the For-Next loop is executed, the value specified by the initial value is added to and assigned to the numeric variable.
The Exit For command is executed to forcefully exit the loop while the For ... To ... Step - Next is executing.
Control is moved from outside the For block to within using the Goto command, etc. Moving control from inside the block to outside it cannot be done.
Example
Output the Judgement Result of each processing unit(unit1-unit4).
DATA&=0
For I&=1 To 4
DATA&=UnitJudge(I&)
If DATA&=1 Then
DrawTextG "Unit"+Str$(I&)+" Result: OK",100,I&*100,0
Else
DrawTextG "Unit"+Str$(I&)+" Result: NG",100,I&*100,0
EndIf
Next