Beckhoff Automation GmbH & Co. KG TX1200 — 7.1.2.1 Arrays

Reference programming 7.1.1.17 DT Date and time. The least siginificant digit is one second. The data type is handled internally like DWORD. 7.1.2 User Data Types 7.1.2.1 Arrays One-, two-, and three-dimensional fields (arrays) are supported as elementary data types. Arrays can be defined both in the declaration part of a POU and in the global variable lists. Syntax: :ARRAY[ .. , .. ]OF LowLim1 , LowLim2 identify the lower limit of the field range; UpLim1 and UpLim2 identify the upper limit. The range values must be integers. Example: Card_game: ARRAY [1..13, 1..4] OF INT; Initializing of Arrays You can initialize either all of the elements in an array or none of them.

Example for initializing arrays: arr1 : ARRAY [1..5] OF INT := 1,2,3,4,5; arr2 : ARRAY [1..2,3..4] OF INT := 1,3(7); (* kurz fьr 1,7,7,7*) arr3 : ARRAY [1..2,2..3,3..4] OF INT := 2(0),4(4),2,3; (* kurz fьr 0,0,4,4,4,4,2,3 *) Example for the initialization of an array of a structure: TYPE STRUCT1 STRUCT p1:int; p2:int; p3:dword; END_STRUCT arr1 : 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 arr1 [3] to arr1 [10] are therefore initialized with 0. Array components are accessed in a two-dimensional array using the following syntax: [Index1,Index2] Example: Card_game[9,2] If you define a function in your project with the name CheckBounds [ } 218] , you can automatically check for out-of-range errors in arrays ! The name of the function is fixed and can only have this designation. TX1200 186 Version: 1.3 Type Lower bound Upper bound Memory use DATE AND TIME _ _ DT DT#1970-01-01-00:00 DT#2106-02-06-06:28:15 32 Bit