LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Array Element Using Array Reference

Solved!
Go to solution

Hello,

 

I am trying to figure out how to delete an element of an array using only the array reference. This is a 1D array that won't have very many elements, but the elements can be of any type (numeric, string, cluster, etc.). I can successfully add elements to the array, but cannot figure out how to implement delete.  Currently, I'm changing the "deleted element" value to 0 (or equivalent) and moving it to the end of the array. This isn't sufficient as I need the initialized size of the array to decrease when I delete an element. I've attached an image demonstrating the results I want.

 

The Delete From Array Function won't work because I only have access to the array reference. To my knowledge, I can only use Invoke Nodes and Property Nodes. I tried seeing if I could disable a singular element, but the disable and enable properties affect all array elements. I've also tried passing in a blank variant constant to the Value property of the control reference, but this didn't work. I've attached an image of this attempt and the resulting error message.

 

I have also attached an image of how I am successfully adding an element to the array.

 

Any ideas would be greatly appreciated!

0 Kudos
Message 1 of 3
(660 Views)
Solution
Accepted by justine97

You can read the "value" property, use "delete from array", then write the "value" property. This is quite slow relative to using the terminals, but if you're not doing it frequently it should work fine.

Message 2 of 3
(647 Views)

Gregory,

 

This worked perfectly - thank you!

 

Picture of solution attached if anyone is interested.

0 Kudos
Message 3 of 3
(616 Views)