I am trying to search an array that may or may not have multiple entries for what I am searching. I know for a fact there is 2 entries and the strings match, but the Search 1D Array is returning -1. The code works when only 1 matching entry is present. How do I get the system to return both (i have it in a while loop so it does run to the end of the search array) Is this normal function?
Solved! Go to Solution.
put it in a do while loop pass the index where the item was found into a shift register. Wire that or that plus 1 into the start index in the search 1D array. Stop the loop when you get a negative 1 for the index of element or'ed with a front panel abort button. Pass the list of indexes out of the loop with tunnel mode indexing and conditional turned on. set the conditional on that outgoing variable that is set to be false when the index is less than zero.
>> I know for a fact there is 2 entries and the strings match, but the Search 1D Array is returning -1
I believe you're doing something wrong to get that result. Can you show your code?
Also, there's a search function in the OpenG array tools that will return an array of indices containing all of the locations of the search string.
I know for a fact there is 2 entries and the strings match, but the Search 1D Array is returning -1. The code works when only 1 matching entry is present. How do I get the system to return both (i have it in a while loop so it does run to the end of the search array) Is this normal function?
It will always find the first one. If it returns -1 if there are multiple matches, something is wrong. I suspect that your while loop is not wired up correctly. What are the tunnel flavors (indexing, last value, etc.)? What determines the stop condition?
We can probably tell immediately what's wrong if you could attach a simplified VI and an array of strings. There are millions of ways to "put things in a while loop", and only a small fraction will result in reasonable code.
You can calculate from the number of iterations how many matches there are. If you also need their indices, follow the earlier advice.
Hope you have got enough info on the solution for your issue (Looping/using VIPM Tools)
Also its always better to share your LabVIEW Code to guide you in better way.
Note:Try to sharing the LV with Lower Version LV2017/Lower
Thanks for the suggestions. I was not aware of the conditional tunnel so that will be very helpful in the future. Instead of manipulating with code. I am using LV2015. I was able to get it working now.
Try something like this:
I am not aware of these OpenG tools yet so good to know, thank you. I will do some more research on these.