LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resizeable storage in an object?

Solved!
Go to solution

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.

0 Kudos
Message 1 of 7
(2,391 Views)

You can put an array in a cluster; and in LV arrays are resizeable.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 7
(2,387 Views)

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.

0 Kudos
Message 3 of 7
(2,371 Views)

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?

Download All
0 Kudos
Message 4 of 7
(2,368 Views)

@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.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 7
(2,354 Views)
Solution
Accepted by JohnCook

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

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
Message 6 of 7
(2,352 Views)

Thank you kindly Sir!!

 

And thanks to Dr. Powell for his SQLite library too, I use it and it works!

0 Kudos
Message 7 of 7
(2,342 Views)