ValueIndex Property

Applies to TestComplete 14.10, last modified on June 5, 2019

The object-driven testing (ODT) functionality is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can create custom classes in your scripts. For more information, see Alternatives to the ODT functionality.

Description

Use the PropValueSet.ValueIndex property to get the index of a Value in the PropValueSet collection.

Declaration

PropValueSetObj.ValueIndex(Value)

Read-Only Property Integer
PropValueSetObj An expression, variable or parameter that specifies a reference to a PropValueSet object
Value [in]    Required    String    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Value

Specifies the value whose index should be got.

Property Value

The index of a Value in the PropValueSet collection.

Remarks

If you use DelphiScript, you need to enclose Value in square brackets, i.e. ValueIndex[Value].

Example

The following example finds a value in the PropValueSet collection, obtains the value’s index in the collection and checks whether the value will be processed by the Run method.

JavaScript, JScript

function PropValueSetSample()
{
  // Obtains the specified class
  var MyClassObj = ODT.Classes.MyClass;
  // Obtains the PropValueSet collection
  var PropValueSetObj = MyClassObj.PropValueSet("MyProperty");

  // Obtains the index of a value in the collection
  var Indx = PropValueSetObj.ValueIndex("New Value");

  // Checks whether the value belongs to the collection and whether it will be processed
  if ((Indx > 0) && (PropValueSetObj.Checked(Indx)))
    Log.Message("The value will be processed");

}

VBScript

Sub PropValueSetSample

  ' Obtains the specified class
  Set MyClassObj = ODT.Classes.MyClass
  ' Obtains the PropValueSet collection
  Set PropValueSetObj = MyClassObj.PropValueSet("MyProperty")

  ' Obtains the index of a value in the collection
  Indx = PropValueSetObj.ValueIndex("New Value")

  ' Checks whether the value belongs to the collection and whether it will be processed
  If Indx > 0 And PropValueSetObj.Checked(Indx) Then
    Log.Message "The value will be processed"
  End If

End Sub

DelphiScript

procedure PropValueSetSample();
var MyClassObj, PropValueSetObj, Indx;
begin
  // Obtains the specified class
  MyClassObj := ODT.Classes.MyClass;
  // Obtains the PropValueSet collection
  PropValueSetObj := MyClassObj.PropValueSet['MyProperty'];

  // Obtains the index of a value in the collection
  Indx := PropValueSetObj.ValueIndex['New Value'];

  // Checks whether the value belongs to the collection and whether it will be processed
  if (Indx > 0) and (PropValueSetObj.Checked[Indx]) then
    Log.Message('The value will be processed');

end;

C++Script, C#Script

function PropValueSetSample()
{
  // Obtains the specified class
  var MyClassObj = ODT["Classes"]["MyClass"];
  // Obtains the PropValueSet collection
  var PropValueSetObj = MyClassObj["PropValueSet"]("MyProperty");

  // Obtains the index of a value in the collection
  var Indx = PropValueSetObj["ValueIndex"]("New Value");

  // Checks whether the value belongs to the collection and whether it will be processed
  if ((Indx > 0) && (PropValueSetObj["Checked"](Indx)))
    Log["Message"]("The value will be processed");

}

See Also

Count Property
Values Property
Checked Property

Highlight search results