LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically set # of elements in Array to Cluster vi

Solved!
Go to solution
I am using the Array to Cluster vi in the Arrays palette.  It requires you to right click on the vi and manually set the number of elements.  Otherwise it will always create a cluster with 9 elements, no matter what the size of your array.  Is there a way to programatically set this number of elements?  I am converting from cluster to array to cluster, and I want to be able to change my cluster with typdef without changing anything else in my code.  Is there a way to do this?
0 Kudos
Message 1 of 5
(3,554 Views)

No.

 

The cluster wire has to know everything about the data in it at development time. You are efectively asking LV to let you define that wire contents at run time. This would be interesting (and handy sometmites) but it would be a real hit on trying to allocate memory when we don't know what would be in that buffer (wire) when we allocate the space.

 

Tell us more about your code and maybe w can offer another approach that will work for you.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 5
(3,546 Views)
Solution
Accepted by topic author j_osh_o
If your cluster contains only fixed-size elements (no strings or arrays), the typecast function will do what you want.
Message 3 of 5
(3,526 Views)
I am working on a CLD practice exam.  I am trying to make an application that is easily expandable.  I am using typedefs for a cluster of LEDs.  I want to be able to be able to add more booleans to the cluster without breaking the code.  I also want to be able to handle the booleans in the cluster as an array.  This requires converting the cluster to array, and then array back to cluster.  I will try with typecast as suggested by nathand.
Download All
0 Kudos
Message 4 of 5
(3,514 Views)
Type cast works both for converting from array to cluster and cluster to array.  I can wire in my type def to the type cast function, so this way I can add booleans to my type def cluster without breaking my code, which is what I wanted.  Thanks nathand!
0 Kudos
Message 5 of 5
(3,482 Views)