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

Page 1033

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

1031

In the programm beyond the upper limit of the array "a" is exceeded:

PROGRAM PLC_PRG
VAR
a: ARRAY[0..7] OF BOOL;
b: INT:=10;
END_VAR
a[b]:=TRUE;

In this case the implicit call to the CheckBounds function preceding the assignment
effects that the value of the index is changed from "10" into the upper limit "7".
Therefore the value TRUE will be assigned to the element a[7] of the array. This is how
attempted access outside the field range can be corrected via the function
CheckBounds.

Structures
Structures are created as "DUT" (Data Type Unit) objects via the Add Object dialog.
They begin with the keywords TYPE and STRUCT and end with END_STRUCT and
END_TYPE.

Attention: In contrast to »PLC Designer« V2.3 TYPE in structure declarations must be
followed by a ":" !

The syntax for structure declarations is as follows:
TYPE <structurename>:
STRUCT
<declaration of variables 1>
.
.
<declaration of variables n>
END_STRUCT
END_TYPE
<structurename> is a type that is recognized throughout the project and can be used
like a standard data type.
Interlocking structures are allowed. The only restriction is that variables may not be
assigned to addresses (the AT declaration is not allowed!).

Advertising