LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add element to array of cluster

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. 

 

 

*************************************************
CLD
*************************************************
0 Kudos
Message 1 of 5
(3,158 Views)

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.

0 Kudos
Message 2 of 5
(3,153 Views)

Eric, can you provide an example using scripting?

*************************************************
CLD
*************************************************
0 Kudos
Message 3 of 5
(3,143 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(3,125 Views)

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.

0 Kudos
Message 5 of 5
(3,114 Views)