WHILE  DO  END_WHILE

Statement - Repeat a list of statements while a condition is TRUE.

Syntax

    WHILE <BOOL expression> DO
        <statements>
    END_WHILE;

Remarks

  • The statements between DO and END_WHILE are executed while the Boolean expression is TRUE.
  • The condition is evaluated before the statements are executed.
  • If the condition is FALSE when WHILE is first reached, statements are never executed.

  • Loop instructions can lead to infinite loops that block the target cycle.
    Never test the state of an input in the condition because the input is not refreshed before the next cycle.

FBD Language Example

Not available.

FFLD Language Example

Not available.

IL Language Example

Not available.

ST Language Example

iMax := 10; 
WHILE iPos < iMax DO
   MyArray[iPos]:=0;
   iPos +:=1;
END_WHILE;

See Also