Showing results for 
Search instead for 
Did you mean: 

Search through a cluster or clusters in cluster by label-name of a control



is there a function availabe which allows to search through an arbitray cluster by an label-name and if the desired control is found in the cluster, its value should be returned?



The function should receive the cluster to be searched and the label-name of the wanted control. The Output should be the value of the control if the label-name was found within the cluster. If the name was not found, there should be a status e.g. -1 at the output uf the function.


Thanks for your help!




0 Kudos
Message 1 of 5

Try the following to get started.



Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 2 of 5

Thanks for your answer.


So far I've also investigated the same solution. But is it possible to implement a more general solution?

Because when you have for example a cluster, containing sub_clusters and/or numeric or Boolean controls, this solution while not work.


Is there a way to search an arbitrary cluster automatically through all its containing clusters/controls etc. and if the control is found by its label-name, its value is return.



0 Kudos
Message 3 of 5

I wrote this nugget to introduce people to navigating using control refs and dealing with undefined (at dev time) data strutures.


If I was asked to develop the code you are looking for, I would start with the code I included in that Nugget.


More often than not, that example illustrates how much work is involved in developing code "to deal with arbitrary data structures" and setle for the more expedient approach.


But Hey, maybe you are an exception.


Also mentioned in that nugget and follow-up replies is the OPenG Variant functions. You should investigate that as well for more hints as to how to crack the nut.


If you come up with something good feel free to post a zip and link this thread to that nugget so we can find your example when the next person asks.


Have fun!



Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 5

I have two general purpose methods in this instance.  The first is to utilize LV's XML schema and a little XPath:




The second method utilizes Traversal and is contained in the zip file I have attached.  This method is very poorly documented at best (like most scripting).  It was a fun experiment. specifies the callback VI to be used when a control is encountered during the operation called 'FindControls'.  It then calls this traverse operation on the cluster which is based in by reference.  The Callback VI is called for all controls in the cluster, if a Label is specified all matching controls are added to the list.  If no label is specified, all control references contained in the cluster are returned (including those inside subclusters).  You can specify if you only want controls returned and not the clusters. Finally, the Class Operator is removed. 


There is an example included to see how it all works.


Traversing is a great tool to have at your disposal if you are a scripter.

Message 5 of 5