You are here: Core Reference > Coding > Logic > Add the First Instance of a Direct Variable to a Function Block Diagram

Add the First Instance of a Direct Variable to a Function Block Diagram

To add the first or only instance of a direct variable to a Function Block Diagram:

  1. Display the Database Bar (see Display an Explorer Bar in the ClearSCADA Guide to ViewX and WebX Clients).
  2. In the Database Bar, select the database item that represents the direct variable that you want to add to the Function Block Diagram. For example, if you want to add the value of a point named 'INT 1', select the 'INT 1' point item. When you select the item, keep the left-hand mouse button pressed down.
  3. With the left-hand mouse button still pressed down, drag the item onto the Function Block Diagram display.
    The Add Direct Variable window is displayed.

  4. Use the Add Direct Variable window to define the settings for the direct variable:
    • Name—Enter the name for the direct variable. This name will be used to refer to the variable within the program. A name is entered automatically when you drag a direct variable onto the Function Block Diagram, but you can change it as required.
    • Tag Type—Choose the type of direct variable tag. This can be:
      • Read/Write (%M)—The Function Block Diagram can both read the value and overwrite it with a new value.
      • Read Only (%I)—The Function Block Diagram can only read the value and cannot change it.
      • Write Only (%Q)—The Function Block Diagram cannot read the variable but can write a new value to it.
    • Tag—This is the name of the OPC property that represents the variable that you want to add to the Function Block Diagram. The tag can be an OPC tag (for normal, direct variable values) or an OPC Historic tag (see Add Processed Historic Values to Function Block Diagrams).

      ATTENTION: If a database item's name includes parentheses ( ), you should ensure that each opening parenthesis is paired with a closing parenthesis. If this is not the case, any Logic programs that reference the database item will not compile successfully. For example, a point named "Analog Point (4" or "Analog Point (4))" will generate a compile error message. Multiple sets of parentheses will compile successfully, including nested parentheses. For example, a Logic program can refer to a point named "Analog Point (4)" or "Analog Point (4(x))". For more information, see Limitation for Database Item Names Referenced in Logic Programs in the ClearSCADA Guide to Logic.

    • Type—Choose the type of value. The value type needs to be appropriate to the value that is represented by the selected tag. For more information, please refer to Built-In Data Types.
    • Insert—Choose the type of variable tag that you are adding to the Function Block Diagram. Choose the required type of variable from the combo box (see Function Block Diagram Components).
    • Retained—The Retained feature is designed to be used with internal variables. When selected, it allows the internal variable to be stored and transferred to other servers (in a multi-server setup).

      For more information on the Retain feature, see Using the RETAIN Keyword in an ST Program.

    • No Cache—Use the No Cache check box to determine whether the program uses the latest value or the initial value for a variable on each execution. If you check the No Cache check box, the program will use the latest value for the variable rather than the default value. If you clear the No Cache check box, the program will use the default value for the variable on each execution.

      The No Cache feature is especially useful with variables that are used as counts. For more information on the No Cache feature, please refer to Using VAR NOCACHE to Prevent Cached Values Being Used in an ST Program.

  5. Select the OK button to confirm.
    A direct variable tag is added to the Function Block Diagram. You can then draw connections to or from it (see Controlling the Flow of a Function Block Diagram).

If you need to add another instance of the direct variable to your Function Block Diagram, see Add Another Instance of a Direct Variable to a Function Block Diagram.


ClearSCADA 2015 R2