LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Jarrod_S.

New Primitive Function to Search Array of Clusters

Status: New

I'm sometimes amazed how lazy I get. As soon as a cool new feature comes out, like a For Loop with Break, I want something better. I'm tired of writing code to search through an array of clusters for some specific value that matches. I really want LabVIEW to do this for me. This could drastically improve coding efficiency in advanced applications.

 

Imagine we have a new primitive search function that can search an array of clusters for a specific item and return the index of the first match. Then instead of writing this code manually, I could just drop the function and select the type to search by.

 

This:

 cluster_search.PNG

 

becomes this:

new_cluster_search.PNG

Jarrod S.
National Instruments
8 Comments
altenbach
Knight of NI

Sorry, I am a bit confused what you mean with the polymorphic selector. You are severly overloading of the meaning of the word string in the code you are showing (1:datatype, 2:control name, and 3:cluster element name), so it's not clear what refers to what.

 

What if the cluster has multiple strings?

 

Could you describe in a bit more detail how all this should work?

 

 

altenbach
Knight of NI
An alternative code would be to use the suggested "Index & Unbundle Cluster array" (or the " ... by Name" version of same), followed by a plain search array.
Jarrod_S.
Active Participant

Yes, "String" is a bit confusing here. What that should be is the name of the data type. This should be analogous to what shows up in the Unbundle by Name text. If you were searching for a nested item, you'd see "Parent.Child" or whatever.

 

Printing the data type there would be quite insufficient.

Jarrod S.
National Instruments
Jarrod_S.
Active Participant
The advantage of this function over the one you mentioned is that we wouldn't have to create an intermediate array.
Jarrod S.
National Instruments
muks
Proven Zealot
I will call this a luxury and kudo it too...
Jarrod_S.
Active Participant

Luxuries do add up, though. The For Loop with Break was also thought to be such a luxury, which may have been why it took so long to be added. But it's immensely helpful!

 

On a side note, I think my explanation above of what I want to search for is completely misleading. It should be the name of the cluster element, not the data type at all. I should have used an example with a cluster element called "abc" instead of "string."

Jarrod S.
National Instruments
Eric_BOB
Member

hi

There is something like that on MGI cluster library . The name of the vi is "Get Cluster Index.vi"

 

http://www.mooregoodideas.com/goodLabViewStuff.htm

 

You can't see it on the html page, but it is in library when you install it.

Eric

Message Edité par Eric BOB le 01-28-2010 07:19 AM
clendon.gibson@canrig.com
Member

I like this.

 

I do this a lot in my code only I use a second array with whatever key (in the above example string is used as the key), search that array for the index I want and index the cluster for the element I want assuming that the key array and the cluster array are in the same order. (They had better be.)

 

I like your suggestion better. It would be cleaner code and would help prevent bugs caused by not updating the two arrays correctly. (Which can be hard to debug. It leads to weird symptoms.)