LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to empty an array? Just a constant doesn't work.

Hello,
for a reset-function I want to "reset" an array. Meaning to empty it completely. I connected the local variable of the array to a zero constant, which seems to work fine, but as soon as I fill in some new elements in this array, the old elements appear too. Then I tried it by getting the array-size and letting a foor-loop set a constant for each element of the array. Didn't work either.
What can I do? Thanks for the answer.
0 Kudos
Message 1 of 4
(3,065 Views)
Use either Initialize Array or the Delete from Array function. The Initialize Array is probably faster.
Message 2 of 4
(3,065 Views)
If the array control is being set to a zero length array using a local
variable, that should work. It sounds line the contents of the array are
being stored in an internal buffer and new elements are appended to this
buffer, and not to the array defined in the control.

One possibility- loops with shift registers. This is simple and you should
know if you've put some in there!

Second more subtle possibility; if you have a loop and the wire from the
control passes into the loop from the outside, the point of entry of the
wire into the loop contains the data that was in the control at the time the
loop started; subsequent writes to this control by a local will not change
the data in the loop. You need to move the control terminal inside the loop
for changes
in the control data to be picked up by code within the loop. You
could of course use a local inside the loop, however I believe the terminal
is a more efficient way of accessing the control than a local is, and the
point of most frequent access should have the terminal.

Dennis Knutson wrote in message
news:506500000005000000383F0000-999158726000@exchange.ni.com...
> Use either Initialize Array or the Delete from Array function. The
> Initialize Array is probably faster.
0 Kudos
Message 3 of 4
(3,065 Views)
An empty array constant should work.What you see is not an array with elements but an empty array with some non zero default value.
Make sure that you assign a zero default value to an array element.After emptying via the local all values should be grayed out and have the zero value.
greetings from the Netherlands
Message 4 of 4
(3,065 Views)