Hello altronics,
So regarding your two questions, so instead of passing 0 as the compare
function in ListFindItem (which causes CVI to do a memcpy on the two
strings), you can pass the CStringCompare function which will perform a
strcmp comparison on the two strings.
The reason why you are getting a fatal run-time error when you pass
CStringCompare as the compare function is most likely because you are
not passing a null terminated string or a large enough array into the
Item to Find parameter of the ListFindItem function.
So I wrote up some sample code, which works on my end. It should
help you reformulate how you are calling the ListFindItem
function. Hope it helps.
#include "toolbox.h"
int main (int argc, char *argv[])
{
char *dog = "dog";
char *cat = "cat";
int result;
ListType newList;
char *itemToFind = "cat";
newList = ListCreate(sizeof(char *));
if (newList)
{
ListInsertItem(newList, &dog, END_OF_LIST);
ListInsertItem(newList, &cat, END_OF_LIST);
}
result = ListFindItem (newList, &itemToFind, FRONT_OF_LIST, CStringCompare);
return 0;
}
Wendy L
LabWindows/CVI Developer Newsletter