Drive plc developer studio – Lenze DDS v2.3 User Manual

Page 259

Advertising
background image

Drive PLC Developer Studio

IEC 61131-3 Data types

10-3

l

DDS EN 2.3

Initializing arrays:

Either all elements of an array are initialized, or none.

Examples of array initializations:

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 for the initialization of an array within 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);

Elements without pre-assigned values are initialized with the basic type’s default initial value. In the
above example, the elements anarray[6] to anarray[10] are therefore initialized with 0.

Tip!

The function CheckBounds in library CheckBounds.lib may be used to automatically check whether
an array exceeds its limits.
Also note CheckBounds.lib.

Library CheckBounds.lib

The library CheckBounds contains the global variable

g_bErrorCheckBounds.

Open the library management with Window

WLibrary Manager.

Insert the library from the library folder. Via the menu command Insert

WAdditional Library,

you can select the library and insert it into the actual project.

Select the library in the library management. On the index card Global Variables, the
variable and additional information are listed.

Note!

The global variable

g_bErrorCheckBounds monitors accesses to an array that is not within the

defined limits.

The function CheckBounds of the library recognizes that the target system uses an array outside
its defined limits.

The global variable

g_bErrorCheckBounds is set to TRUE.

The status TRUE is not set back during runtime. If the status = TRUE, at least once an array
has been accessed outside its defined limits.

Show/Hide Bookmarks

Advertising