LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

lsearch function from Borland C++ does not exist in LW CVI

Solved!
Go to solution
IS there an equivalent function to borlands c++ lsearch in LabwindowsCVI?
0 Kudos
Message 1 of 3
(3,010 Views)

As far as I can understand lsearch performs a search in an unordered array of elements. If this is true, I'm afraid the short answer to your question is "no".

Both ANSI C library bsearch ( ) and Programmer's Toolbox BinSearch ( ) functions require the array to be sorted since they try to reduce searching time relying on the sort.

In any case, it seems quite easy to develop your own searching function; in the programmer's toolbox several functions are provided for comparisons that can help you in this task (CStringCompare and CStringNoCaseCompare are specific to string camparisons).



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(3,009 Views)
Solution
Accepted by topic author WDLV

Roberto is correct, there is no one function to sort an unordered array in CVI (lsearch is not part of the ANSI C standard).  However, you can create your own by using the qsort and bsearch methods in the ANSI C library or any of the sorting methods and the BinSearch from the Programmer's Toolbox.  If you don't want your array to be sorted, you can create a function that makes a copy of the array, sorts it, then searches it and returns the results.

 

I filed a product suggestion to the developers to look at the possibility of including this in a later version of CVI.

Eric B.
National Instruments
0 Kudos
Message 3 of 3
(2,975 Views)