RemoveOptionByIndex Method

Applies to TestComplete 15.40, last modified on July 05, 2022

Description

Use this method to delete an option from the current section. The option is identified by its index in the option collection of the current section. To get the number of options in this collection, use the OptionCount property.

Declaration

ProgObj.RemoveOptionByIndex(Index)

ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section
Index [in]    Required    Integer    
Result None

Applies To

The method is applied to the following objects:

Parameters

The method has the following parameter:

Index

Specifies the index of the option to be deleted. The index is zero-based, that is, the first option has index 0, the second - 1, and so on. Index of the last option is OptionCount-1.

Result Value

None.

Remarks

Be careful when modifying the system registry using the Section object methods. Incorrect modifications made to the registry may affect the functionality of your operating system and the applications installed.

Example

The following code snippet uses the RemoveOptionByIndex method to delete a value from the registry key.

JavaScript, JScript

function Test()
{

  var Key, Value, Indx;

  // Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey\\Subkey", HKEY_CURRENT_USER);
  // Specifies the index of the value to be deleted
  Indx = 0;
  if (Indx < Key.OptionCount)
    {
    // Removes the specified value
    Key.RemoveOptionByIndex(Indx);
    Log.Message("The value has been deleted");
}

}

Python

def Test():

  # Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey\\Subkey", HKEY_CURRENT_USER)
  # Specifies the index of the value to be deleted
  Indx = 0
  if (Indx < Key.OptionCount):
    # Removes the specified value
    Key.RemoveOptionByIndex(Indx)
    Log.Message("The value has been deleted")

VBScript

Sub Test

  Dim Key, Value, Indx

  ' Gets an object for the Windows system registry key
  Set Key = Storages.Registry("TestKey\Subkey", HKEY_CURRENT_USER)
  ' Specifies the index of the value to be deleted
  Indx = 0
  If Indx < Key.OptionCount Then
    ' Removes the specified value
    Key.RemoveOptionByIndex(Indx)
    Log.Message("The value has been deleted")
  End If

End Sub

DelphiScript

procedure Test();
var Key, Value, Indx;

begin

  // Gets an object for the Windows system registry key
  Key := Storages.Registry('TestKey\Subkey', HKEY_CURRENT_USER);
  // Specifies the index of the value to be deleted
  Indx := 0;
  if Indx < Key.OptionCount then
    begin
    // Removes the specified value
    Key.RemoveOptionByIndex(Indx);
    Log.Message('The value has been deleted');
end;

end;

C++Script, C#Script

function Test()
{

  var Key, Value, Indx;

  // Gets an object for the Windows system registry key
  Key = Storages["Registry"]("TestKey\\Subkey", HKEY_CURRENT_USER);
  // Specifies the index of the value to be deleted
  Indx = 0;
  if (Indx < Key.OptionCount)
    {
    // Removes the specified value
    Key["RemoveOptionByIndex"](Indx);
    Log["Message"]("The value has been deleted");
}

}

See Also

OptionCount Property
RemoveOption Method
DeleteSubSectionByIndex Method

Highlight search results