Declaring external variables by dragging and dropping global variables into POUs

If you declare an →external variable (VAR_EXTERNAL), e.g. as described under "Declaring variables", it is imperative that you know the name and data type of the basic →global variable. If you declare an external variable and no global variable has been declared for it, the application cannot be built because the external variable cannot be resolved.

If the global variables have been declared in a global-object, the application navigator provides the possibility to declare external variables in the POUs and to have the declarations based on the already existing global variables:

  1. Make the application navigator visible.

  2. Expand the global-object that is displayed below the folder Global variables (or a subfolder of it).
    Result: The global variables of the global-object are displayed.

  3. Select one or several of these global variables.

  4. Press and hold the primary mouse button and drag the global variables onto a →POU ( usually displayed below the folder Project blocks ).

  5. Release the primary mouse button.
    Result: The external variables are automatically declared in the POU. They are listed in the list of the declared variables of the →graphical editor or within the section VAR_EXTERNAL ... END_VAR of the →textual editor . A description and/or a comment (that has been defined for the global variable) is transferred to the external variable. If the POU already contains an external variable with the same name, logi.CAD 3 updates the external variable according to the specifications of the global variable.

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg It is also possible to drag the global object itself onto the POU in the application navigator. The result of this action depends on the type of the POU type:

  • For an ST-program, a reference to the global object is added to the POU (see "Creating and using a global-object" for details).

  • For the other POUs, the external variables are declared in the POU (as described above).

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg It is possible to undo or redo the declaration of the external variables within the application navigator.

If a global object has been assigned to a →resource, it is also possible to declare the external variables in a →POU in →FBD based on the global variables of this global object:

  1. Make the application navigator visible.

  2. Expand the folder Resource-Globale Variables and the assigned global object to display its global variables.
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg See "Creating and using a global-object" for directives on how to assign a global object to a resource.

  3. Select one or several of these global variables.

  4. Press and hold the primary mouse button and drag the global variables into an FBD-editor.

  5. Release the primary mouse button.
    Result:

    1. If the target of the dragging action is the list of the declared variables, the external variables are automatically declared in POU. A description and/or a comment (that has been defined for the global variable) is transferred to the external variable.

    2. If the target of the dragging action is the drawing field, one →value field is additionally created for each external variable.

    3. Independent of the target: If the POU already contains an external variable with the same name, logi.CAD 3 updates the external variable according to the specifications of the global variable.

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg For a better visualization of the result, the external variables are selected in the list of declared variables. The list of declared variables is automatically opened for this purpose, if needed.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg It is possible to undo or redo the creation of value fields and the declaration/update of the external variables within the FBD-editor.