Statement - Iteration of statement execution.

Syntax

   FOR <index> := <minimum> TO <maximum> BY <step> DO
        <statements>
   END_FOR;

index = DINT internal variable used as index.
minimum = DINT expression: initial value for index.
maximum = DINT expression: maximum allowed value for index.
step = DINT expression: increasing step of index after each iteration (default is 1).

Remarks

The BY <step> statement can be omitted. The default value for the step is 1.

ST Language

iArrayDim := 10;

(* resets all items of the array to 0 *)
FOR iPos := 0 TO (iArrayDim - 1) DO
   MyArray[iPos] := 0;
END_FOR;

(* set all items with odd index to 1 *)
FOR iPos := 1 TO 9 BY 2 DO
   MyArray[ipos] := 1;
END_FOR;

FBD Language

Not available.

LD Language

Not available.

Fixed_Image See also

IF  WHILE  REPEAT  CASE  EXIT


Created with the Personal Edition of HelpNDoc: Effortlessly bring your documentation online with HelpNDoc