LOOP WHILE
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
LOOP WHILE <condition>
<Code lines>
ENDLOOP
Description
Executes the code in the loop until the <condition> evaluates False.
Diagram
Returned value type
None
Parameters
Parameter | Description |
<Condition> |
Expression evaluating to True or False |
<Code lines> |
Code that is performed each time the loop is executed. The loop will be terminated immediately in one of the following cases:
|
Remarks
The evaluation of the condition is performed at the start of each loop. Therefore 'LOOP WHILE False' will execute never and 'LOOP WHILE True' will result in an endless loop.
Examples
i := 1
loop while i <= 5
sme ('I is: ' + format (i, onezero))
i += 1
endloop
i := 1
run := True
loop while run
sme ('I is: ' + format (i, onezero))
i += 1
if i > 5
run := False
endif
endloop
loop while i <= 5
sme ('I is: ' + format (i, onezero))
i += 1
endloop
i := 1
run := True
loop while run
sme ('I is: ' + format (i, onezero))
i += 1
if i > 5
run := False
endif
endloop