IsSameComObject

See Also: FlexCOM Helper Functions, IsComObject, IsNullComObject, IsComObjectCreated, pvComObject

Purpose

Returns True if the two parameters are of type variant and point to the same COM object.

Return Type

Boolean

Syntax

(IsSameComObject( {vComObject1 }, {vComObject2 } ))

Where:

 

What It Does

This Boolean function returns True if the two parameters are of type Variant and point to the same COM object.

Use this function in place of the expression (vComObject1 = vComObject2). Such an expression is illegal and would raise a runtime error.

The following example loops through a collection automation object and uses the IsSameComObject function to determine the index of the current object in the collection.

Handle hoTestNode

Variant vTestNode vCurrentNode

Integer iNode icNode iCurrent

 

Object oNodes is a cComafNodes // cComAutomationObject

End_Object

 

Send AttachActiveObject of oNodes

 

If (IsComObjectCreated(oNodes)) Begin

    // Get IDispatch* of the current node

    Get ComCurrentNode of oNodes To vCurrentNode

    // Get the number of nodes in the collection

    Get ComCount of oNodes To icNode

 

    // iterate through the nodes collection

    Move 1 To iNode

 

    While ((iNode <= icNode))

        // Get a IDispatch* to the i'th node

        Get ComItem of oNodes iNode To vTestNode

        // test If this is the current node

        If (IsSameComObject(vCurrentNode, vTestNode))) Begin

            Move iNode To iCurrent // store the index

            Move icNode To iNode    // jump out of the Loop

        End

        Increment iNode

    Loop

End