Instructions
204Compiler
© 2013 Conrad Electronic
Do While a<10
a=a+2
End While
Do While a
a=a*2
x=a
End While
Exit Instruction
If an Exit instruction is executed within a loop than the loop will be left and the program execution
starts with the next instruction after the While loop.
Example:
Do While 1 ' Endless loop
a=a+1
If a>10 Then
Exit ' Will terminate loop
End If
End While
4.3.6.3 For Next
A For Next loop is normally used to program a definite number of loop runs.
For Counter Variable=Startvalue To Endvalue Step Stepwidth
Instructions
Next
The Counter Variable is set to a Start Value. Then the instructions are repeated until the End Value
is reached. With each loop run the value of the Counter Variable is increased by one step width
which may also be negative. The stating of the step width after the End Value is optional. If no Step
Width is stated it has the value 1.
Since the For Next loop will be used to especially optimized the counter variable must be of the
Integer type.
Example:
For i=1 To 10
If i>a Then
a=i
End If
a=a-1
Next