LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract data from array of clusters if condition met

Solved!
Go to solution

Hi guys, a bit of a background first.

I want to search for a specific model of USB-DAQ, and if it's found, I want to use its data further in the program (S/N, DevName, Product type).

I made a bit of code, where I search for the devices, but having trouble with the next part.

 

I'm looping through all available devices, then creating an array of clusters, if the product info matches, I would like to use the remaining data from that cluster.

Any help would be appreciated.

 

Thanks,

Johnny

0 Kudos
Message 1 of 6
(1,504 Views)
Solution
Accepted by topic author JohnatanBravo

Can there be more than one match?

 

If you are only looking for the first match, use "search array" (instead of the second FOR loop) and use the result to index into the cluster array.

If you are looking for multiple matches, use your current code and a conditional tunnel.

Message 2 of 6
(1,489 Views)

Here's one possible way to create an array of clusters containing only matching devices.

(Sorry, I don't have drivers installed, so everything is broken for me).

 

altenbach_0-1631621867113.png

 

Maybe if you would explain what you mean by "use the remaining ...", we could give more specific advice. 🙂

 

0 Kudos
Message 3 of 6
(1,469 Views)

Hi altenbach,

 

Thanks a lot for the suggestion, I went with your first post- as I'm only after noticing the new one now.

I did what you said and it's exactly what I needed.

 

I'm only looking for one match, as only one USB-6126 will be plugged into the PC at any time.

Funny enough, I tried using the "search array" previously and always got errors, I didn't realize I had to wire the "element" with the specific data type.

 

I'll take a look at your other suggestion in a while.

Thanks a lot!

0 Kudos
Message 4 of 6
(1,455 Views)

You probably need a bit more code to deal with the possibility that there is no match (i.e. search returns -1). You need to decide what result should be returned if this happens.

 

My second solution is more explicit, because you would get an empty array in that case.

0 Kudos
Message 5 of 6
(1,442 Views)

I only want to run this bit of code at the "first call", and if the 6216 is not connected I display an error for user to see and set a bool- which if not true, won't let the test to be carried out.

The example I attached with the bit of extra code I have does just that for me.

0 Kudos
Message 6 of 6
(1,429 Views)