Requirement: A programming object (POU or GVL) of a project is open.
-
Click “Edit Declare Variable”.
The “Declare Variable” dialog opens.
-
Select the desired scope for the array from the drop-down list “Scope”.
-
Enter an identifier for the array in the “Name” input field.
-
Click the arrow 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:
1
and3
).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 field “Result” displays 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:
1
and4
, Dimension 3:1
and2
).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.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 dialog “Declare Variable” the field “Data type” displays the array.
-
To modify the initialization values of the array, click the arrow button (
) next to the “Initialization value” input field.
The “Initialization Value” dialog opens.
-
Select the line of the array element whose initialization value you wish to modify. Example: Select array component [1, 1, 1].
-
Enter 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 “Declare Variable” dialog, CODESYS displays the initialization values of the array (example:
{4, 23(0)]
). -
You can optionally enter a “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.