Requirement: A project is open.
-
In the Device tree of your project, select the application in which the global variables are to be valid.
-
In the context menu, click “Add Object Global Variable List”.
CODESYS inserts the “GVL” in the device tree under the application and opens it in the editor.
-
Click “Edit Auto Declare”.
The ⮫ Declare Variable dialog opens.
-
In the list box “Scope”, select the entry “VAR_GLOBAL”.
-
In the field “Name”, enter a name for the global variable.
-
Select a data type from the “Data type” list box.
-
If your variable is to have an initialization value other than the standard initialization value, click
next to the “Initialization value” field.
The “Initialization Value” dialog opens.
-
Double-click the “Initialization value” field of your variable and enter the desired valid value.
-
Click “OK”.
The initialization value is displayed in the “Declare Variable” dialog.
-
Activate one of the “flags” if necessary.
-
Confirm your entries by clicking the button “OK”.
CODESYS inserts the declared variable in the GVL.
The global variable is available in the total application of your project.