Admin Production ni-theme
Current Publication

ListFindItem

LabWindows/CVI

ListFindItem

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

Purpose

This function searches a list for an item that matches the item you specify in pointerToItem.

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 one-based.

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

To start searching from the last item in a list, pass 0 or the constant END_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 4.0 and later

Examples

Refer to the following examples that use the ListFindItem function:

  • apps\uirview\uirview.cws

    Open example
  • TDM Streaming\tdmsReader.cws

    Open example