Declaring global variables which are available within the application Permalink

Requirement: A project is open.

  1. In the Device tree of your project, select the application in which the global variables are to be valid.

  2. 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.

  3. Click “Edit  Auto Declare”.

    The dialog opens.

  4. In the list box “Scope”, select the entry “VAR_GLOBAL”.

  5. In the field “Name”, enter a name for the global variable.

  6. Select a data type from the “Data type” list box.

  7. If your variable is to have an initialization value other than the standard initialization value, click _cds_icon_input_assistent.png next to the “Initialization value” field.

    The “Initialization Value” dialog opens.

  8. Double-click the “Initialization value” field of your variable and enter the desired valid value.

  9. Click “OK”.

    The initialization value is displayed in the “Declare Variable” dialog.

  10. Activate one of the “flags” if necessary.

  11. 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.