LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Indexing Data from a cluster to an array

How can I index the data of the cluster (see file)? after the input is done, the user press sample and the data of the cluster has to be written in the array (each time you press sample its one line in the array)
The data has to be changed into string because it hat to be saved in a file. But before the transformation there have to be done some parser - action (not realized in this file).

Thank you all for help!!!
0 Kudos
Message 1 of 16
(3,989 Views)
You have to build the array or create an array of a certain size and then replace its elements...see attached code picture.

You do not necessarily need to convert it to text to save it (unless some other application is to read the files and cannot be made to read anything else...), just save it as a binary file (write one array element at a time to the file...see examples found here and shipped with LabVIEW).
Message 2 of 16
(3,989 Views)
Thank you for your answer. It seems to me a interesting solution. But how can I create the structure outside the loops where the data is put in? Can you please explain it.
0 Kudos
Message 3 of 16
(3,989 Views)
Not sure what you mean. In the example I initialize the shift register with an array built using a constant of the cluster (right click on the cluster and select create constant), you can avoid using that if you instead do the shift register initialization within the loop, then you can use the cluster control itself as the input to the initialize array (just make a case with the loop index wired to it and do an initialization in the case of it being zero...).

Please explain the question in more detail and I'll try to provide the answers:-)
0 Kudos
Message 4 of 16
(3,989 Views)
I've found it 🙂 it was the cluster constant that I didn't know. But what kind of array do you use in your example in the while-loop. Is it an array of cluster or what? How can I create it?
Sorry. I'm just beginner in G programming.

Thank you very much for your help!!! 😉
0 Kudos
Message 5 of 16
(3,989 Views)
Hi mads

I've tried you create my own programm, because I have to split up the cluster first to proof data, check it and give a hint to the user. Now I've tried to do it that way. but i have still the problem by indexing tha data so that it is written in the right line. I have put the file onto. so you may take a look at it and tell what is wrong with the index.
Thank you very much for your time & your help!!!
0 Kudos
Message 6 of 16
(3,989 Views)
Sebastian, if you save your code as 6.0 I will be happy to see if I can help

Paul.S
0 Kudos
Message 7 of 16
(3,989 Views)
Hi,

You have combined different parts of the example code that does not quite belong together...In the example where I initialize the array prior to filling it I use the replace function...not the insert. If you use an insert function it will resize the array every time. Resizing arrays is ineffective, if the arrays are small and/or memory/speed is less important though don't bother initializing the array, just add cluster elements using the build array function (as in the first example).

You also convert the cluster to an array, that's not necessary, what you want is to create an array of such clusters, and then put the clusters into that array (i.e. wire clusters straight into build array or replace array element, n
o conversion to array first...if you do that you will get an array of arrays...).

Attached is one example where you can add up to 10 config sets (clusters)...each time you add a cluster there is a VI that checks whether the input data is OK...if it is, and there is still place in the array for another test it will add it...

And another example that builds the array continously...that will make the array resize every time an element is added which is a slower and more memory expensive method, but easier...
Download All
0 Kudos
Message 8 of 16
(3,989 Views)
Hi Paul

I've saved the file in both Version. So I hope you can read it! Thanks for your help!
0 Kudos
Message 9 of 16
(3,989 Views)
Sorry

But I have to convert and check the data before it's been written in the array. I have changed it in my VI and hope, you'll understand what I mean with that.
First the data should be cheked and some messages be send to the front panel. After the user had read the warnings he should change input (or not if not necessary) and then press the "Save Data" button. And now the hole data should be transferred into string and set into the array. Convert to string for to save data as spreadsheet ASCII file, so you can create a file without LV and load it there instead of do the input in the front panel.
Thank you for your extensive help!!!!!!
This LabView is going to confuse me a little bit 🙂
0 Kudos
Message 10 of 16
(3,989 Views)