beautypg.com

For loop, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 765

background image

L-force | PLC Designer

General Editors

DMS 4.1 EN 03/2011 TD29

763

Example:

CASE INT1 OF
1, 5: BOOL1 := TRUE;
BOOL3 := FALSE;
2: BOOL2 := FALSE;
BOOL3 := TRUE;
10..20: BOOL1 := TRUE;
BOOL3:= TRUE;
ELSE
BOOL1 := NOT BOOL1;
BOOL2 := BOOL1 OR BOOL2;
END_CASE;

FOR loop
With the FOR loop one can program repeated processes.
Syntax:
INT_Var :INT;
FOR := TO {BY } DO

END_FOR;
The part in braces {} is optional.
The are executed as long as the counter is not greater than
the . This is checked before executing the so that the
are never executed if is greater than .
When are executed, is increased by . The step size
can have any integer value. If it is missing, then it is set to 1. The loop must also end
since only becomes greater.
Example:

FOR Counter:=1 TO 5 BY 1 DO
Var1:=Var1*2;
END_FOR;
Erg:=Var1;