EXIT

Statement - Exit from a loop statement

Remarks

The EXIT statement indicates that the current loop (WHILE, REPEAT or FOR) must be finished. The execution continues after the END_WHILE, END_REPEAT or END_FOR keyword or the loop where the EXIT is. EXIT quits only one loop and cannot be used to exit at the same time several levels of nested loops.

Warning: loop instructions may lead to infinite loops that block the target cycle.

ST Language

(* this program searches for the first non null item of an array *)
iFound = -1; (* means: not found *)
FOR iPos := 0 TO (iArrayDim - 1) DO
   IF iPos <> 0 THEN
      iFound := iPos;
      EXIT;
   END_IF;
END_FOR;

FBD Language

Not available

LD Language

Not available

IL Language:

Not available

See also

IF   WHILE   REPEAT   FOR   CASE