117
C-Control Pro Mega Series
5.3.6.2
Do While
With a while instruction the instructions can depending on a condition be repeated in a loop:
Do While Expression
Instructions
End While
At first the Expression is evaluated. If the result is unequal
that the Expression is again calculated and the entire procedure will constantly be repeated until the
Expression takes on the value 0.
Examples:
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
a=a+1
If
a>10
Exit
End If
End While
5.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.
' Endless loop
Then
' Will terminate loop
0
then the expression is executed. After
© 2008 Conrad Electronic
Need help?
Do you have a question about the C-Control Pro Mega Series and is the answer not in the manual?
Questions and answers