Skip to main content

Section: InstRefs

The section InstRefs defines references to FB instances or structure instances.

SEC InstRefs                                     //optional: yes, modifier: [UPDATE]
    SEC InstRef : <identifier>                   //target: yes, optional: yes, modifier [HIDE,UPDATE]
            Variable := <variable name>;             //optional: no, type: InstancePath
            Desc := <description>;                   //optional: no, type: text
            Optional := TRUE/FALSE;                  //optional: yes, type: BoolFlag
    END_SEC
...
    SEC InstRef_Multi : <identifier>              //optional: yes, modifier [HIDE,UPDATE]
            Variable := <variable name>;             //optional: no, type: InstancePath
            Var_Count := <variable for count>;       //optional: no, type: InstancePath
            Desc := <description>;                   //optional: no, type: text
            Cardinality := [<minimum> .. <maximum>]; //optional: no, type: Cardinality
    END_SEC
END_SEC

Details regarding the syntax of definition types are described in the section Module Declaration.

. Specification:
  • Inst_Ref.Variable defines the input instance path of a variable of type POINTER TO <T> or of type <interface>. (<T> is any structure or FB type)

  • InstRef_Multi.Variable defines the input instance path of type POINTER TO POINTER TO <T> or of type POINTER TO <interface>. (<T> is any structure or FB type)

  • Two different InstRef or InstRef-Multi entries must not use the same variable.

  • The target must uniquely identify the instance reference. This means that there must not exist two different instance reference declarations (section InstRef and InstRef_Multi) with the same target (upper or lower case spelling is not relevant).

  • The input integer variable defined by Var_Count can only be used once in all VarCounts of Slot_Multi or InstRef_Multi. Only integer variables defined by Var_Count of VarArray can be used in parallel to Var_Counts of Slot_Multi or InstRef_Multi.

Example 28. Example
SEC InstRef_Multi : Elements
        Variable    := piElems ;
        Var_Count   := uiArraySize ;
        Desc        := TL.Elems_Desc ;
        Cardinality := [1 .. 10] ;
END_SEC

Among other declarations the declaration part of the function block must contain: uiArraySize : UINT; piElems : POINTER TO Interface;

piElems points to a globally created, correctly initialized ARRAY[0..uiArraySize-1] OF interface or OF POINTER TO <T>, which points to the individual instances. As a result, the i-th object can be accessed by means of piElems[i].