LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

clear an array

How can I clear an array?
0 Kudos
Message 1 of 7
(3,610 Views)
Depends on what you mean; do you want it to have the same size, but with all the values set to zero...or do you want to destroy it and have an array of length 0? IN the latter case you can just have e.g. a case somewhere that lets through the array in one case and sends out an empty one in the other (wire the array through and then set the tunnel to return default if not wired for the other case...e.g.). In the former case you could just get the size of the array and initialize a new one the same size with all zeroes, or you could work with the same array and replace all elements with zeroes.

OR if the array is a control and you want to clear that you could use an invoke node to reset it to default e.g...
0 Kudos
Message 2 of 7
(3,610 Views)
I have an array and ik want to clear it for the next time that the while loop is active.
0 Kudos
Message 3 of 7
(3,610 Views)
Your are thinking about the 2D array in the shift register, right? If so then right click on the left shift register and create an empty 2D array and wire it into the shift register terminal from the outside of the loop. This will initialize the shift register. Uninitilized shift registers are nice to use when you want to keep in memory the results from previous changes, e.g. to use a VI with a loop as a global (check out "functional globals"), otherwise though you should initialize the shift registers.
Message 4 of 7
(3,610 Views)
I think what you want to do is to wire in an empty array into the shift register to initialize it. The way your vi is now, when you run it a second time, the array results from the previous run is still there. If you initialize the shift register, the array will be cleared every time you run the vi.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 7
(3,610 Views)
Thanks, it works !
0 Kudos
Message 6 of 7
(3,610 Views)
i have a problem in clearing array.
1. i have a vi witch on a button click add element in array ,and plot the values on graph.
2. second time when i run vi on graph i get all the values witch i got in first run pluse the values on second run
2. i want my graph should not plot values i got in first run
3. if I follow your suggestion ,with shift reg.
I got only single point on graph.
4. I want all the points witch I added in my array at second run

so please help me
Shital
0 Kudos
Message 7 of 7
(3,610 Views)