Requirement: A POU or GVL of a project is open.
-
Click the command.
The Auto Declare dialog opens.
-
Select the desired scope for the array from the Scope list box.
-
Specify an identifier for the array in the Name input field.
-
Click the
button next to the Data Type input field and select the Array Assistant entry from the selection menu. -
In the input fields Dimension 1, type in the lower and upper limit of the first dimension of the array (example:
1and3).The field Result displays the 1st dimension of the array (example:
ARRAY [1..3] OF ?). -
In the input field Basic type, type in the data type of the array or use the
Input Assistant or the Array Assistant (example: DINT).The Result field shows the data type of the array now (example:
ARRAY [1..3] OF DINT). -
Define the second and third dimensions of the array according to steps 5 and 6 (example: Dimension 2:
1and4, Dimension 3:1and2).The Result field displays the array with the defined dimensions:
ARRAY [1..3, 1..4, 1..2] OF DINT. The array consists of 3 * 4 * 2 = 24 elements.
Tip In an array of variable length, declare the dimension limits with an asterisk placeholder (
*). Arrays of variable length are permitted to be used only in VAR_IN_OUT declarations of function blocks, methods, or functions.Example of a 2-dimensional array of variable length:
aiUnknownLengthData : ARRAY [*,*] OF INT; -
Click OK.
In the Auto Declare dialog, the Data Type field shows the array.
-
To modify the initialization values of the array, click the
button next to the Initialization value input field.The Initialization Value dialog opens.
-
Select the line of the array element whose initialization value you want to modify. Example: Select array component [1, 1, 1].
-
Specify the desired initialization value in the input field below the list and click button Use value on selected lines (example: value
4).CODESYS displays the changed initialization value of the selected line.
-
Click OK.
In the Initialization value field of the Auto Declare dialog, CODESYS displays the initialization values of the array (example:
[4, 23(0)]). -
You specify an optional Comment in the input field.
-
Click OK in order to conclude the declaration of the array.
CODESYS adds the declaration of the array to the declaration part of the programming object.
For more information, see: data type ARRAY OF