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

Page 1031

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

1029

Example of the initialization of an array of a structure:
Structure definition:

TYPE STRUCT1
STRUCT
p1:int;
p2:int;
p3:dword;
END_STRUCT
END_TYPE

Array initialization:

ARRAY[1..3] OF STRUCT1:= [(p1:=1,p2:=10,p3:=4723),(p1:=2,p2:=0,p3:=299),
(p1:=14,p2:=5,p3:=112)];

Example of the partial initialization of an Array:

arr1 : ARRAY [1..10] OF INT := [1,2];


Elements to which no value is pre-assigned, are initialized with the default initial value
of the basic type. In the example above, the elements anarray[6] to anarray[10] are
therefore initialized with 0.

Accessing array components:
Array components are accessed in a two-dimensional array using the following syntax:
<Field_Name>[Index1,Index2]
Example:

Card_game [9,2]


Check Functions
In order to a proper access to array elements during runtime the function CheckBounds
must be available to the application. Therefore add the object "POUs for implicit
checks" to the application using the Add Object dialog. Mark the checkbox related to
the type CheckBounds, choose an implementation language and confirm your settings
with Open, whereon the function CheckBound will be opened in the editor
corresponding to the implementation language selected. Independently of that choice
the declaration part is preset and may not be modified except for adding further local
variables! A proposal default implementation of the function that might be modified
is given in the ST Editor.

Advertising