04-21-2020 03:37 PM
Hello,
I've been doing some forum homework and it would seem that it is not possible to do resizeable storage within a class, since a class is a type of cluster, which does not allow resizeable storage.
I'm trying to do a resizeable array within a class.
I'm used to C++ where you could create a linked-list or other dynamic object and add as much as you like and iterate through the dynamic structure. Is there a way to do this in LabVIEW?
Thanks,
-John C.
Solved! Go to Solution.
04-21-2020 03:53 PM
You can put an array in a cluster; and in LV arrays are resizeable.
04-21-2020 04:12 PM
All sorts of resizable datatypes can be put in a cluster. Technically, resizable types involve a pointer, and only the pointer is actual part of the cluster; but in LabVIEW, unlike C++, you don't need to deal with the pointer yourself. Just drop an array/set/variant/object inside your cluster.
04-21-2020 04:18 PM
Yes, well I did try that, I have a class with a cluster of private data, which seems to be the only way to have data in a class, and the cluster contains two arrays.
I've got a test program and when I first wrote it, I used the BuildArray icon to add new elements to the arrays. BUT, it didn't actually add anything, it simply clobbered over what was there. Then I tried calling it twice, to make sure it worked, and then I saw that the storage at the cluster level was not expanding due to BuildArray. I also tried InsertIntoArray with the same results.
So, how do you expand the storage at the cluster level?
04-21-2020 04:30 PM
@JohnCook wrote:
Yes, well I did try that, I have a class with a cluster of private data, which seems to be the only way to have data in a class, and the cluster contains two arrays.
I've got a test program and when I first wrote it, I used the BuildArray icon to add new elements to the arrays. BUT, it didn't actually add anything, it simply clobbered over what was there. Then I tried calling it twice, to make sure it worked, and then I saw that the storage at the cluster level was not expanding due to BuildArray. I also tried InsertIntoArray with the same results.
So, how do you expand the storage at the cluster level?
Didn't see anything wrong in the 2 VIs, but I can't try it because of missing files.
04-21-2020 04:34 PM
The For Loop tunnels for your object should be shift registers. That way the *same* object you pass in to the right-side shift register on one iteration is the one that comes out of the left-side shift register on the next iteration.
The way you have it, each iteration starts fresh with the original object fed in via tunnel. Each iteration replaces the output tunnel with the object modified during that iteration. When the loop ends, you'll have only the info from the very last iteration.
-Kevin P
04-21-2020 05:05 PM
Thank you kindly Sir!!
And thanks to Dr. Powell for his SQLite library too, I use it and it works!