LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you create an array of clusters dynamically

I have created a cluster of 3 elements (string, I32, I32) dynamically then I want to create a 1D array of clusters dynamcally as well, but I am having trouble creating the array of clusters .  If anybody has any suggestions please help.  I will really appreciate it, Thank You
0 Kudos
Message 1 of 10
(6,753 Views)
You can build arrays of clusters just like you can with any data type, as long as the clusters are the same. You cannot build arrays of clusters containing different types of clusters. Exactly what are you trying to do "dynamically"?
PaulG.
Retired
0 Kudos
Message 2 of 10
(6,743 Views)
As Paul said, the procedure is the same, you use initialize array.  What you would want to do would be done as follows:



I created a 30 elemnt array of your specified cluster, but the 30 could be a control, or calculated value.

Message Edited by Matthew Kelton on 10-04-2007 02:35 PM

0 Kudos
Message 3 of 10
(6,737 Views)
I really do appreciate your reponses and I have tried doing what has been suggested.  The data is being assembled into a cluster, 3 elements (string, I332, I32) but my data is changing for each cluster but the type is always the same (string, I32, I32).  But I want to display and store data in different array elements, a 1D array of clusters is sufficient, but as the loops go through the iteration I keep losing the previous data element.  Any suggestions on this is appreicated, Thank you. 
0 Kudos
Message 4 of 10
(6,706 Views)
Why don't you post your code so we can tell you what you are doing wrong?

It sounds like you need to use a shift register.  If you are in a for/while loop and modifying data, then you will lose your modifications if you use a tunnel, because the tunnel gives you the original array every time.

If you use a shift register instead, then when you modify your array and wire it to the output shift register, the next loop iteration will have the updated array in the input shift register.
0 Kudos
Message 5 of 10
(6,699 Views)
The most efficient way to build an array is to accumulate one on the output of a FOR loop. Also good is to preallocate the number of elements you are going to need outside the loop (of either type) and pass this array into a shift register. You then use the replace array element function to put the real data into the array.

But as said elsewhere, the best solution would be if we could see your code.

Mike..

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 10
(6,690 Views)
I have a sample of my code, the one part that is giving me trouble, as an attachment.  It takes in a spreadsheet file (tab delimited) and reads the data; it leaves the string as a string but convert the numeric strings to numbers.  It passes the data to bundle as a cluster and at this point I initialize an array and do a replace array with a shift register.  The outside FOR loop are the rows (# to read in) and inside are the columns.  The data is bundled up fine and each row has different data, so I want to place each cluster with different data into a 1D array and this is my trouble. I would really appreciate any help.  Thank You.
0 Kudos
Message 7 of 10
(6,670 Views)
You are not building your array correctly.  What you are doing is taking a single element array of data you just read and replacing it with an empty data set.

Look at the following ways of doing this.  The one in the middle is only available in later versions of LV, but is supposed to handle memory more effeciently.  But, both the top and middle basically do the same; I preallocate memory for the rows and columns, then replaces the element of the array with the current row and columns data.  The output of the loop with have a 2-D array of all the data.

The bottom example does create an empty array before the loop runs and uses the indexing feature of the for loop to build the array for you.  All gve you the same result as far as data in your array is concerned.


Message Edited by Matthew Kelton on 10-05-2007 02:56 PM

0 Kudos
Message 8 of 10
(6,648 Views)
I wanna say thank you, all three worked out great!
0 Kudos
Message 9 of 10
(6,637 Views)
That should have said:

"The bottom example does NOT create an empty array..."
0 Kudos
Message 10 of 10
(6,635 Views)