Admin Production ni-theme
Current Publication

ListFindItemInRange

LabWindows/CVI

ListFindItemInRange

size_t ListFindItemInRange (ListType listToSearch, const void *pointerToItem, ssize_t startingPosition, ssize_t endingPosition, CompareFunction compareFunction);

Purpose

This function searches a list for an item that matches the item you specify in pointerToItem. LabWindows/CVI searches the list using the range specified by startingPosition and endingPosition, including both indices. If endingPosition is before startingPosition, the search is performed in reverse order.

Parameters

Input
Name Type Description
listToSearch ListType The list in which to search for the specified item.
pointerToItem const void * A pointer to the item you want to search for in the list.
startingPosition ssize_t The position of the item in the list where you want to start the search. You can specify a number from 1 to the number of items in the list. Positions in the list are 1-based.

To start searching from the first item in a list, pass -1 or the constant FRONT_OF_LIST.

To start searching from the first item in a list, pass 0 or the constant END_OF_LIST.
endingPosition ssize_t The position of the item in the list where you want to end the search. You can specify a number from 1 to the number of items in the list. Positions in the list are 1-based.

To stop searching on the last item in a list, pass -1 or the constant END_OF_LIST.

To stop searching on the first item in a list, pass 0 or the constant FRONT_OF_LIST.
compareFunction CompareFunction A comparison function to use to compare the specified item to the items in the list.

The compare function must have the following prototype:

int CVICALLBACK CompareFunction(void *item1, void *item2);


Ensure that the compare function returns the following values:

  • Returns a negative number if item1 is less than item2
  • Returns 0 if item1 is equal to item2
  • Returns a positive number is item1 is greater than item2
If you pass 0 for this parameter, ListFindItemInRange calls the ANSI C Library function memcmp to compare items.

This instrument driver provides several useful comparison functions:

ShortCompare
IntCompare
FloatCompare
DoubleCompare
CStringCompare
CStringNoCaseCompare

Return Value

Name Type Description
foundPosition size_t Returns the index of the first item in the list at or after the startingPosition whose contents match the specified item.

Zero (0) is returned if no matching item is found in the list.

Additional Information

Library: Programmer's Toolbox

Include file: toolbox\toolbox.h

LabWindows/CVI compatibility: LabWindows/CVI 2012 and later