R. E. Cook
Home 
Contact Us 

Dr. Cook
Resume 

RunningShoes Library for WinRunner 
RunningShoes 

Custom WinRunner Functions 
and Utilities,
to Your Specs
Custom 

A Random Collection of WinRunner Solutions
Solutions 

Creating DLLs for WinRunner 
"DLLs Demystified" 
(Mercury Interactive's Worldwide Users Conference 2000)

A function to determine whether an array contains an element.

 

Both versions of this function determine whether the specified element is in the array. The versions differ only in that one uses a case-sensitive match and the other is not case sensitive.

Both of the functions take an element and an array as parameters. (Note that while the array is used as an in parameter, it is declared inout because WinRunner does not allow declaring an array in. The functions do not alter the arrays.) 

The functions return TRUE if the element is in the array, or FALSE otherwise. 

The code for both versions is in a text file to avoid browser format mangling. View ElementInArray.txt.


Usage

# Create the array.
number_arr[] = { 1, 2, 3 };

# Capture a number to test.
number = SomeFunction(...);

# Test whether the number is in the array.
rc = ElementInArray(number , number_arr);

 

# Create an array of expected names.
exp_names_arr[] = { "Anul", "Billy Bob", "Chukwumoke", "Daphne" };

# Capture the actual name from the AUT.
rc = obj_get_text("First Name", name_act);

# Test whether the actual name is in the expected array.
rc = ElementInArray(name_act, exp_names_arr);

# Set the test result.
if(rc == TRUE)
   status = PASS;
else
   status = FAIL;

 



Top of  This Page | R. E. Cook Home Page

Copyright R. E. Cook Consulting, 2000 - 2011.
All rights reserved.

The site is designed to look best when viewed with Internet Explorer 5.0 - 8.0. Results with other browsers will probably deviate from what is intended.

NOTE: This website refers to registered trademarks and service marks that are owned by other companies, including Mercury Interactive, WinRunner, TestDirector, TSL, Microsoft, Windows.