TimerProc Property

Applies to TestComplete 14.92, last modified on September 16, 2021

Description

Use this property to obtain or specify the name of the routine which will be called by the timer (the period between calls is specified by the Interval property).

Note: The routine name must be specified in the format “unit_name.routine_name”.

If the specified routine does not exist, an error will occur when the timer calls the routine.

Declaration

TimerObj.TimerProc

Read-Write Property String
TimerObj An expression, variable or parameter that specifies a reference to a Timer object

Applies To

The property is applied to the following object:

Property Value

A string holding the routine name.

Remarks

The script execution is single-threaded. When TestComplete executes the timer routine, the other routines are delayed (if you have several timers, the execution of their routines is postponed). So, it is recommended that the code of the timer routine be as fast as possible.

Example

The code below demonstrates how you can add a new Timer object to the Timers collection and modify the timer’s properties.

JavaScript, JScript

function TestProc()
{
  // Adds a new object to the Timers collection
  Timer1 = Utils.Timers.Add(10000, "Unit1.TimerRoutine", true);

  // Modifies the timer’s properties
  Timer1.Name = "MyTimer";
  Timer1.Interval = 20000;
  Timer1.TimerProc = "Timers.NewTimerRoutine";
}

function TimerRoutine()
{
  // Specify your code here.
  // This routine will be executed after the specified timeout expires.
}

function NewTimerRoutine()
{
  // Specify your code here.
  // This is a new timer routine.
}

Python

def TestProc():
  # Adds a new object to the Timers collection
  Timer1 = Utils.Timers.Add(10000, "Unit1.TimerRoutine", True)

  # Modifies the timer's properties
  Timer1.Name = "MyTimer"
  Timer1.Interval = 20000
  Timer1.TimerProc = "Timers.NewTimerRoutine"

def TimerRoutine():
  # Specify your code here.
  # This routine will be executed after the specified timeout expires.
  pass


def NewTimerRoutine():
  # Specify your code here.
  # This is a new timer routine.
  pass

VBScript

Sub TestProc
  ' Adds a new object to the Timers collection
  Set Timer1 = Utils.Timers.Add(10000, "Unit1.TimerRoutine", True)

  ' Modifies the timer’s properties
  Timer1.Name = "MyTimer"
  Timer1.Interval = 20000
  Timer1.TimerProc = "Timers.NewTimerRoutine"
End Sub

Sub TimerRoutine
  ' Specify your code here.
  ' This routine will be executed after the specified timeout expires.
End Sub

Sub NewTimerRoutine
  ' Specify your code here.
  ' This is a new timer routine.
End Sub

DelphiScript

procedure TestProc;
begin
  // Adds a new object to the Timers collection
  Timer1 := Utils.Timers.Add(10000, 'Unit1.TimerRoutine', true);

  // Modifies the timer’s properties
  Timer1.Name := 'MyTimer';
  Timer1.Interval := 20000;
  Timer1.TimerProc := 'Timers.NewTimerRoutine';
end;

procedure TimerRoutine;
begin
  // Specify your code here.
  // This routine will be executed after the specified timeout expires.
end;

procedure NewTimerRoutine;
begin
  // Specify your code here.
  // This is a new timer routine.
end;

C++Script, C#Script

function TestProc()
{
  // Adds a new object to the Timers collection
  Timer1 = Utils["Timers"]["Add"](10000, "Unit1.TimerRoutine", true);

  // Modifies the timer’s properties
  Timer1["Name"] = "MyTimer";
  Timer1["Interval"] = 20000;
  Timer1["TimerProc"] = "Timers.NewTimerRoutine";
}

function TimerRoutine()
{
  // Specify your code here.
  // This routine will be executed after the specified timeout expires.
}

function NewTimerRoutine()
{
  // Specify your code here.
  // This is a new timer routine.
}

See Also

Using Timers
Timer.Interval
Timer.Enabled
Timers.Add

Highlight search results