Interval Property

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

Use the Interval property to get or set the number of milliseconds that should pass between calls to the scripting routine specified by the TimerProc property.

Note: The Interval property specifies the approximate time period for calling the timer routine. The actual period passed between two calls to the timer routine depends on several factors: the number of active timers, the execution time of other timers’ routines, the current load of the system, etc.

Declaration

TimerObj.Interval

Read-Write Property Integer
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

An integer value specifying the time-out in milliseconds.

Remarks

Interval should be greater than 0. If it is 0, the timer will not get triggered.

Windows XP: If Interval is greater than 2147483647, it is set to 1. If Interval is less than 10, it is set to 10.

Windows Server 2003: If Interval is greater than 2147483647, it is set to 2147483647.

Windows 10: The maximum supported Interval value is 1000000. If it is set to a greater value, then the timer will not get triggered.

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
Timers.Add
Timer.TimerProc
Timer.Enabled

Highlight search results