10-24-2013 01:40 AM - edited 10-24-2013 02:03 AM
I have an array of cluster. Cluster contains two elements. How to add an element in cluster at run time on the second position efficiently? In other words dont want another copy of cluster which contains three elements and copy the original two elements plus the new element.
Original array of cluster lets say has two element Temp1 and Pressure 1.
Need to add another element in cluster and now the array of cluster will be Temp1, Volt1 and Pressure 1. So Volt 1 is added to all cluster elements at second order throughout the array of clusters programatically.
10-24-2013 01:50 AM
Hey,
Clusters data types are what they are made of. As you can not change the data type of a control/indicator at run-time, this include modifying clusters. You will have no choice but to have a new cluster made of temp, volt and pressure.
Only solution I could come up with would be to have your cluster array in a VI called in a subpanel. If that subpanel VI is not executing, you'll be able to change the cluster data type through scripting 🙂
Regards,
Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.
10-24-2013 02:04 AM
Eric, can you provide an example using scripting?
10-24-2013 07:23 AM
If you are turning this into an actual application, scripting won't help you at all. What you should do is make your cluster have the 3 elements the whole time. This is why type defs are useful.
10-24-2013 08:06 AM
It is unclear from your original post what the problem you need to solve actually is. Are you trying to create a user interface? Do you need to dynamically add arbitrary data to a data set, or is it a fixed set of functionality that can be dynamically changed in predetermined ways?
Having done it, I will recommend you not try the scripting and subpanels approach. There are almost always better ways.
Remember that your data structures do not need to mirror your user interface. If you were trying to display the temperature, voltage, and pressure data to the user, a multicolumn listbox may be more appropriate than a raw cluster in an array. Internally, this would allow you to maintain the temperature, voltage, and pressure as separate arrays and only display the ones you want in the listbox.
Please give us a more information on the problem so we can help you with an easier solution.