Execute the body for a fixed number.
The for loop is controlled by a start and termination value and an incrementation value that determines the number of loop steps. These values may also be expressions which are evaluated immediately before the loop is entered. The expressions may be of type integer or of type real. If all input values are of type integer the loop variable will also be of type integer. In all other cases the loop variable will be of type real. If the start value is less or equal to the termination value, the loop index is assigned with the starting value and the body of the loop is entered. If the increment is less than zero the loop is entered if the start value is larger or equal to the end value. Each time the body is executed, the loop index is incremented by the incrementation value. If the loop index is equal to the termination value, the body of the loop is performed for the last time. If the loop index is larger than the termination value the body will not be excecuted any longer. For negative increment values the loop is terminated if the loop index is less than the termination value.
Please note that it is not necessary, that the loop index has to be equal to the termination value before terminating the loop. The loop index is set to the termination value when the loop is being left. Please note, that the expressions for start and termination value are evaluated only once when entering the loop. A modification of a variable that appears within these expressions has no influence on the termination of the loop. The same applies to the modifications of the loop index. It also has no influence on the termination. The loop value is assigned to the correct value each time the for operator is executed.
If the for loop is left too early (e.g., if you press Stop and set the PC) and the loop is entered again, the expressions will be evaluated, as if the loop were entered for the first time.
For exported C++ please note the different semantics of the for loop.
|
Start (input_control) |
number -> integer / real |
| Start value for the loop variable. | |
| Default value: 1 | |
|
End (input_control) |
number -> integer / real |
| End value for the loop variable. | |
| Default value: 5 | |
|
Step (input_control) |
number -> integer / real |
| Increment value for the loop variable. | |
| Default value: 1 | |
|
Variable (output_control) |
number -> integer / real |
| Loop variable. | |
dev_update_window ('off')
dev_close_window ()
dev_open_window (0, 0, 728, 512, 'black', WindowID)
read_image (Bond, 'die3')
dev_display (Bond)
stop ()
threshold (Bond, Bright, 100, 255)
shape_trans (Bright, Die, 'rectangle2')
dev_set_color ('green')
dev_set_line_width (3)
dev_set_draw ('margin')
dev_display (Die)
stop ()
reduce_domain (Bond, Die, DieGrey)
threshold (DieGrey, Wires, 0, 50)
fill_up_shape (Wires, WiresFilled, 'area', 1, 100)
dev_display (Bond)
dev_set_draw ('fill')
dev_set_color ('red')
dev_display (WiresFilled)
stop ()
opening_circle (WiresFilled, Balls, 15.5)
dev_set_color ('green')
dev_display (Balls)
stop ()
connection (Balls, SingleBalls)
select_shape (SingleBalls, IntermediateBalls, 'circularity', 'and', 0.85, 1.0)
sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')
dev_display (Bond)
dev_set_colored (12)
dev_display (FinalBalls)
stop ()
smallest_circle (FinalBalls, Row, Column, Radius)
NumBalls := |Radius|
Diameter := 2*Radius
meanDiameter := sum(Diameter)/NumBalls
mimDiameter := min(Diameter)
dev_display (Bond)
disp_circle (WindowID, Row, Column, Radius)
dev_set_color ('white')
set_font (WindowID, 'system26')
for i := 1 to NumBalls by 1
if (fmod(i,2)=1)
set_tposition (WindowID, Row[i-1]-1.5*Radius[i-1], Column[i-1]-60)
else
set_tposition (WindowID, Row[i-1]+2.5*Radius[i-1], Column[i-1]-60)
endif
write_string (WindowID, 'Diam: '+Diameter[i-1])
endfor
dev_set_color ('green')
dev_update_window ('on')
for returns 2 (H_MSG_TRUE) if the evaluation of the expression yields no error. endfor (as operator) always returns 2 (H_MSG_TRUE)
for is reentrant, local, and processed without parallelization.
Basic operators