AMT Help Files

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:
  • When a BREAK command is encountered
  • When a GOTO command is encountered that refers to a label outside the loop
  •  When an exit command is encountered. This commands jumps out of the current routine and therefore exits the LOOP also.

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 (ionezero))
    i += 1

endloop


i   := 1
run := True
loop while run

    sme ('I is: ' + format (ionezero))
    i += 1
    if i > 5
        run := False
    endif

endloop