Declaring external variables by using a list of the content assist in FBD

If you declare an →external variable (VAR_EXTERNAL) as described under "Declaring variables in FBD", 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.

The best practice is to use the second list of the content assist of the FBD-editor so that an external variable is declared based on an already existing global variable and so that it is entered in a →value field:

  1. Position the mouse pointer over an empty space – where you need the value field with the external variable.

  2. Start the content assist: From the context menu of the FBD-editor, select Content Assist. Alternative: Press Ctrl+Space.
    Result: A list is displayed with all →variables already declared in the POU and with all available →functions and →function blocks.

  3. Now press Ctrl+Space again.
    Result: The list changes to display the global variables (icon images/download/thumbnails/413893074/VarGlobal-version-1-modificationdate-1533808466516-api-v2.png ) that have been declared in →programs or →resources (within a PLC-object). The entry for the global variable includes its data type. Example: portSetting (LocalConfiguration.local) : INT – Meaning: This is the global variable with name portSetting and →data type INT. The global variable is declared in the →configuration LocalConfiguration and the resource local .

  4. Enter one or more letters. This displays a list with all elements fitting your input.
    Example: Enter port. The list provides all global variables containing the text port.

  5. Click an element in the list or select it (by using the mouse or the cursor movement keys) and press the Enter-key .
    If you want to close the list without any action, click the primary mouse button outside the input field or press the ESC-key.

  6. Position the value field in the FBD-editor by pressing the primary mouse button or the Enter-key. If the external variable does not exist yet, it is automatically declared and listed in the list of the declared variables. A description and/or a comment (that has been defined for the global variable) is transferred to the external variable.

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg The application navigator provides the possibility to declare external variables and to have the declarations based on the already existing global variables. This is done when you drag the global variables from a global-object onto a →POU. Details: See "Declaring external variables by dragging and dropping global variables into POUs".