L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 522

Advertising
background image

L-force | PLC Designer

Data types in PLC Designer

520

DMS 3.2 EN 02/2011 TD29



Initializing Arrays:

Example for complete initialization of an array:

arr1 : ARRAY [1..5] OF INT := 1,2,3,4,5;

arr2 : ARRAY [1..2,3..4] OF INT := 1,3(7); (* short for
1,7,7,7 *)

arr3 : ARRAY [1..2,2..3,3..4] OF INT := 2(0),4(4),2,3;

(* short for 0,0,4,4,4,4,2,3 *)

Example of the initialization of an array of a structure:

TYPE STRUCT1

STRUCT

p1:int;

p2:int;

p3:dword;

END_STRUCT

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.

Advertising