LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

define array size in class private section

Solved!
Go to solution

Trying to make a class object that has an array.   The array element is a cluster that contains timestamp and value.

How do I specify an array size of 3600 elements in the class private section?

0 Kudos
Message 1 of 5
(1,502 Views)
Solution
Accepted by shuttlefan

Put the array in the class private data control.

Type "3599" in the index field.  This will move it to the 3600th position.

The values will be greyed out.  Click in one of them and type in the existing value, then click out of it and it will then be bolded.

 

Adding in the 3600th value will have filled in all values from the 1st to the 3599th value with defaults, so you now have a 3600-length array.  Right click it, choose data operations, then choose make current value default.  Save the class private data and that is your new default.

 

Note that this doesn't prevent someone later on writing an empty array or an array of any other size to the class data.  If you need to prevent that too, you'll need to add checks to the accessor VI you create.

Message 2 of 5
(1,493 Views)

Thanks!  The "Click in one of them and type in the existing value" was the key.  This explains why I was getting 0 size before.

 

0 Kudos
Message 3 of 5
(1,480 Views)

Extending on this, what if I want a an array buffer of objects?

When I drag in the obj, its greyed out.

So do I need to instantiate an object with default values and then put that in the array?

 

0 Kudos
Message 4 of 5
(1,312 Views)

If you create your array of objects, then right-click on any object in the array (not the array border) and select "Data operations ► Reset to default value", that should have the same effect where it fills in that object and all of the ones above it with bolded array elements.

0 Kudos
Message 5 of 5
(1,305 Views)