Delete Method

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use this method to remove the specified Timer object from the TimersObj collection.

Declaration

TimersObj.Delete(Index)

TimersObj An expression, variable or parameter that specifies a reference to a Timers object
Index [in]    Required    Variant    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Index

Specifies the name of the Timer object to be deleted or its index in the collection. The first object in the collection has index 0, the second - 1, etc. The total number of objects is specified by the Count property. If the specifies timer does not exist, an error will occur.

Result Value

None.

Remarks

The timer cannot be edited, deleted or disabled inside the timer handler routine. If you try to do this, the TestComplete engine will freeze or even crash. This happens due to restrictions of the internal Timer procedure. These restrictions cannot be removed.

To ensure the correct behavior of the timer, add the following check inside the timer handler routine:

JavaScript, JScript

if (!TimerRoutine)
{
  timerRoutine = true;
}

Python

if not TimerRoutine:
   TimerRoutine = True

VBScript

If Not TimerRoutine Then
   TimerRoutine = True
End If

DelphiScript

if not TimerRoutine then
begin
  TimerRoutine := True;
end;

C++Script, C#Script

if (!TimerRoutine)
{
  timerRoutine = true;
}

Example

The code below demonstrates how you can delete the specified Timer object from the Timers collection.

JavaScript, JScript

function TestProc()
{
  // Deletes the first object in the Timers collection
  Utils.Timers.Delete(0);
  // ...
}

Python

def TestProc():
  # Deletes the first object in the Timers collection
  Utils.Timers.Delete(0)
  # ...

VBScript

Sub TestProc
  ' Deletes the first object in the Timers collection
  Call Utils.Timers.Delete(0)
  ' ...
End Sub

DelphiScript

procedure TestProc;
begin
  // Deletes the first object in the Timers collection
  Utils.Timers.Delete[0];
  // ...
end;

C++Script, C#Script

function TestProc()
{
  // Deletes the first object in the Timers collection
  Utils["Timers"]["Delete"](0);
  // ...
}

See Also

Using Timers
Timers.Clear
Timers.Add
Timers.Items

Highlight search results