LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically set array size

Solved!
Go to solution

Hi everybody!

 

I have an array of cluster (each cluster contains 4 values) and depending on user interactions, new clusters are added to the array. I'd like to implement a "Clear" button which deletes all the elements inside the array but I can't find a solution so far. The best I can do is to set all the cluster elements to 0 but the cluster itself is still in the array.

 

Does anybody know how to do that?

 

Many thanks,

 

Julien

0 Kudos
Message 1 of 8
(2,867 Views)

I would assume delete array subset will do it.

Something like this:

delete.png

 


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 2 of 8
(2,865 Views)
Solution
Accepted by topic author jfcors

Hi jfcors,

 

the cluster has to stay in the array as it defines the datatype of the array.

 

You also seem to mis-understand the term "empty array": an array is empty when there are no elements in it!

 

Snippet:

check.png

 

@aCe:

Your example only deletes one element in an array, but not the whole array! Sorry, it's correct...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(2,864 Views)

@GerdW: It does delete everything. Smiley Happy See array length wired to the length input.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 4 of 8
(2,858 Views)

Thanks a lot!

 

Indeed it wasn't clear. What I wanted is to remove all the elements of the array, except the first one so that the array type is still defined.

 

About your solution:  you show two ways to do it right? What are the names of the subvis you use? I couldn't find them in the Array palette.

 

Cheers,

Julien

0 Kudos
Message 5 of 8
(2,852 Views)

@jfcors wrote:

Thanks a lot!

 

Indeed it wasn't clear. What I wanted is to remove all the elements of the array, except the first one so that the array type is still defined.

 

 


The array type is also defined if the array is empty. No need to keep one element for that.

0 Kudos
Message 6 of 8
(2,849 Views)

Hi jfcors,

 

IndexArray, InitArray and ReshapeArray. All to be found on the Array functions palette...

 

And the picture is a snippet. You can download and put it in your block diagram.

There's a context help entry for snippets. Ever considered to read the help?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(2,846 Views)

Thanks for your help, it works perfectly.

 

I read the help all the time, but sometimes it is easier to ask for help directly.

 

Bests,

Julien

0 Kudos
Message 8 of 8
(2,840 Views)