InSet Function

Applies to TestComplete 15.47, last modified on January 20, 2023

Checks whether a particular set has a definite member.

Declaration

InSet(MemberSetName) Parameters
Member [in] Required Integer
SetName [in] Required Variant
Result     Boolean  

Description

Use the InSet function to determine whether the SetName set has a member with a name or a value specified by the Member parameter. So, for the Memb = 10 statement the results for the InSet(Memb,MySet) and InSet(10,MySet) functions will be the same.

Parameters

The method has the following parameters:

Member

The member name or member value whose existence in the SetName set you want to check.

SetName

The set whose member you want to check for existence.

Return Value

True if the Member is contained in the set and False otherwise.

Remarks

When the ordinal value of the sought member is greater than 31, the function always returns False.

Example

The code below creates a set of values using the MkSet function and then checks whether the created set contains the value 5.

JavaScript, JScript

function InSetExample()
{
  var Item0 = 0;
  var Item1 = 5;
  // ...
  var ItemN = 31;
  
  var MySet = MkSet(Item0, Item1, ItemN);
  
  if (InSet(5, MySet))
    Log.Message("The set contains the specified value.")
  else
    Log.Message("The set doesn't contain the specified value.");
  
}

Python

def InSetExample():

  Item0 = 0;
  Item1 = 5;
  # ...
  ItemN = 31;
   
  MySet = MkSet(Item0, Item1, ItemN);
   
  if (InSet(5, MySet)):
    Log.Message("The set contains the specified value.");
  else:
    Log.Message("The set doesn't contain the specified value.");

VBScript

Sub InSetExample

  Item0 = 0
  Item1 = 5
  ' ...
  ItemN = 31
  
  MySet = MkSet(Item0, Item1, ItemN)
  
  If InSet(5, MySet) Then
    Log.Message("The set contains the specified value.")
  Else
    Log.Message("The set doesn't contain the specified value.")
  End If 
  
End Sub

DelphiScript

function InSetExample();
var Item0, Item1, ItemN, MySet;
begin

  Item0 := 0;
  Item1 := 5;
  // ...
  ItemN := 31;
  
  MySet := MkSet(Item0, Item1, ItemN);
  
  if InSet(5, MySet) then
    Log.Message('The set contains the specified value.')
  else
    Log.Message('The set doesn''t contain the specified value.');
  
end;

C++Script, C#Script

function InSetExample()
{
  var Item0 = 0;
  var Item1 = 5;
  // ...
  var ItemN = 31;
  
  var MySet = MkSet(Item0, Item1, ItemN);
  
  if (InSet(5, MySet))
    Log["Message"]("The set contains the specified value.")
  else
    Log["Message"]("The set doesn't contain the specified value.");
  
}

See Also

MkSet Function

Highlight search results