DebugAgent.TreatResultPointersAs Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

If the tested application is an Open Application, TestComplete has access to the application’s internal methods, properties and objects. Some methods may return pointers to objects or interfaces (for instance, a method can return a reference to the IDispatch interface, or to a TForm object). In some cases, TestComplete is unable to determine the resulting type of a method and this may cause an error when you call the method from scripts.

Using the TreatResultPointersAs method, you can specify whether the scripting engine should treat the resulting pointer as a reference to an object or to an interface. This will guarantee the correct processing of a method call and will help you avoid the error (you will see the error message in the test log).

Declaration

DebugAgent.TreatResultPointersAs(Value)

Value [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Value

One of the following values that specify how the problematic pointers should be treated:

Value Description
0 TestComplete uses its own algorithm to determine the type of the resulting value.
1 TestComplete treats the resulting pointer as a pointer to an interfaced object.
2 TestComplete treats the resulting pointer as a pointer to an object.

Result Value

None.

Remarks

Settings made by a call to the TreatResultPointersAs method affect it until you call a method with another value. To restore the default parameter processing, pass 0 to the TreatResultPointersAs method.

Example

The code below demonstrates how you can command TestComplete to treat the resulting pointer values in a certain way by using the TreatResultPointersAs method.

JavaScript, JScript

function DebugAgentExample()
{
  ResTreatedByTestComplete = 0;
  ResAsPointerToObj = 2;
  
  // Commands TestComplete to use its own algorithm to determine the type of the resulting value
  DebugAgent.TreatResultPointersAs(ResTreatedByTestComplete);
  // ...
  // All the resulting pointer values are determined by Testcomplete
  // ...
  
  // Commands TestComplete to treat pointers as pointers to objects
  DebugAgent.TreatResultPointersAs(ResAsPointerToObj);
  // All the resulting pointer values are treated as pointers to objects
  // ...
  
}

Python

def DebugAgentExample():
  ResTreatedByTestComplete = 0
  ResAsPointerToObj = 2
  
  # Commands TestComplete to use its own algorithm to determine the type of the resulting value
  DebugAgent.TreatResultPointersAs(ResTreatedByTestComplete)
  # ...
  # All the resulting pointer values are determined by TestComplete
  # ...
  
  # Commands TestComplete to treat pointers as pointers to objects
  DebugAgent.TreatResultPointersAs(ResAsPointerToObj)
  # All the resulting pointer values are treated as pointers to objects
  # ...

VBScript

Sub DebugAgentExample

  ResTreatedByTestComplete = 0
  ResAsPointerToObj = 2
  
  ' Commands TestComplete to use its own algorithm to determine the type of the resulting value
  DebugAgent.TreatResultPointersAs(ResTreatedByTestComplete)
  ' ...
  ' All the resulting pointer values are determined by Testcomplete
  ' ...
  
  ' Commands TestComplete to treat pointers as pointers to objects
  DebugAgent.TreatResultPointersAs(ResAsPointerToObj)
  ' All the resulting pointer values are treated as pointers to objects
  ' ...
  
End Sub

DelphiScript

function DebugAgentExample;
var ResTreatedByTestComplete, ResAsPointerToObj;
begin
  ResTreatedByTestComplete := 0;
  ResAsPointerToObj := 2;
  
  // Commands TestComplete to use its own algorithm to determine the type of the resulting value
  DebugAgent.TreatResultPointersAs(ResTreatedByTestComplete);
  // ...
  // All the resulting pointer values are determined by Testcomplete
  // ...
  
  // Commands TestComplete to treat pointers as pointers to objects
  DebugAgent.TreatResultPointersAs(ResAsPointerToObj);
  // All the resulting pointer values are treated as pointers to objects
  // ...
  
end;

C++Script, C#Script

function DebugAgentExample()
{
  ResTreatedByTestComplete = 0;
  ResAsPointerToObj = 2;
  
  // Commands TestComplete to use its own algorithm to determine the type of the resulting value
  DebugAgent["TreatResultPointersAs"]( ResTreatedByTestComplete );
  // ...
  // All the resulting pointer values are determined by Testcomplete
  // ...
  
  // Commands TestComplete to treat pointers as pointers to objects
  DebugAgent["TreatResultPointersAs"]( ResAsPointerToObj );
  // All the resulting pointer values are treated as pointers to objects
  // ...
  
}

See Also

Calling Methods and Properties of Open Applications' Objects
About Open Applications
Debug Info Agent

Highlight search results