LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search in an array of cluster

Hi!

Is there a smart way to search in an array of clusters.

For example: You have an array of a cluster with a digital control and a string control.
And you want to search for a specific value in the digital control.
What is the best way to that?

Is there a way, instead of a foor-loop and unbundle, like search 1-D array where you can ignore the string value.

If I use the search function I need to specify both the numeric and the string, but I'm only intrested in the numeric.
0 Kudos
Message 1 of 4
(5,569 Views)
As you suspected, you do need to use a loop and unbundle the cluster to search for only one element of the cluster. If you use a While loop instead of a For loop, you can stop the search on the first occurrance. You can build in searches more complex than just = (>= and/or <=, etc).
See the attched example.
0 Kudos
Message 2 of 4
(5,569 Views)
If you are always wanting to search this array based on the value of one particular value in the cluster, something you can do is when creating the cluster array, create two arrays that relate to each other on an element-by-element basis.

One array contains the values that you are going to want to search. The other array contains a cluster with all the other values. Searching the "key" array gives you an index that you can use to index the correct element from the other data array.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 4
(5,569 Views)

I came across the same problem and I came up with this, using "Cluster to Array of VData" from OpenG :

Search_ClusterArray.png

 

It's probably not very efficient, but it does the trick.

What struck me was that you can convert a variant to an array of variants this easily!

0 Kudos
Message 4 of 4
(4,733 Views)