Name Property

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

Description

Use the Name property to get or set the name of the Timer object. Once you assigned a name to an object, you can use this name to obtain the object from the Timers collection.

Declaration

TimerObj.Name

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 object name.

Remarks

The name of the Timer object is not used to address this object in scripts. So, the name can be any string, it may not meet the naming rules of the selected scripting language.

The names of Timer objects are not unique. The Timers collection may hold two Timer objects having the same name. So, if you retrieve an object by name, the collection will return the "oldest" object having this name.

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.Items
Timers.Add

Highlight search results