LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reset an Array

Hello all,

 

I have written a program with an array. I would like to reset the array (empty the array) with a control button. Is this possible? I can only empty or reinitialize the array if i use Right mouse and select data operations -> empty array.

Now I found out one thing the array is inside a if structure this was necessary for the purpose of my program and i found out I cant do anything with the array as long it is inside this If structure. I found something here on the forum but I dont know how to recreate this. Could anybody give me some advice.

I have added my program but i think this wont work cause it needs an DLL and some hardware. But aybe someone understand whats happening when he see the block diagram. 

Screenshot_3.png

I think this snippet would do what i need. But i dont understand this code completely. It seems like the String, Display and Array inside the if structure are linked to the ones inside the while loop? I notice this small icon (home, a house). How could i get this maybe i can figure it out by myself?

 

Thanks in advance.


Raymond

0 Kudos
Message 1 of 19
(7,752 Views)

Maybe I need to explaine myself a little better. The below picture is a part of my code.

 

Screenshot_4.png

So because the array is inside this If structure which is true when a button (from a hardware device) is pressed. I cant do anything with this array. So basically im looking for a way to send the data from this array to "outside" the If structure or something similar. The picture in previous post does this i think.

 

I hope it makes sense what im telling here.

Thanks a lot

 

0 Kudos
Message 2 of 19
(7,747 Views)

Instead of a Feedback Node, use a Shift Register on your loop.  You will need to wire your value to the case structure and out of it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 19
(7,727 Views)

Im sorry i pressed wrong but this is not the solution. Because if a make a shift register of this it will not add data to the array anymore. It overwrite all new data to the first element of the array.

0 Kudos
Message 4 of 19
(7,718 Views)

I created local variables with this it seems i can do stuff with the array inside the if structure. 

 

Screenshot_5.png

 

But im not there yet. If you look to the right If structure i try to set all the elements to 0 when pressing the refresh button. But at the moment the left If structure is enabled all the old data comes back for some kind of reason. Smiley Indifferent

0 Kudos
Message 5 of 19
(7,714 Views)
0 Kudos
Message 6 of 19
(7,708 Views)

@Ray1981 wrote:

Im sorry i pressed wrong but this is not the solution. Because if a make a shift register of this it will not add data to the array anymore. It overwrite all new data to the first element of the array.


So you are using the shift register wrong. Fix that and all's good! Did you wire across the other cases?

 

Now also attach your actual VI instead of pictures. We cannot debug pictures.

 

Once we see what you are doing, it will be trivial to fix. Even with a feedback node, all you need is insert a "select" to conditionally change the feedback node content to an empty array again.

 

Also don't over-engineer your code with blatant overuse of local variables. For example in your very first picture, all you need to reset is the string control, because the others will update from it immediately. Also watch for CPU hogs. Your loop will consume 100% CPU because there is no small wait.

 

0 Kudos
Message 7 of 19
(7,703 Views)

I cant open your solution yours is written with 2016 and I have 2015. But I appreciate your help a lot 🙂

0 Kudos
Message 8 of 19
(7,702 Views)

Hi Altenbach in the original post there was my code. But meanwhile I have changed stuff alllready to try to solve this so I upload the newer version.

 

Next i will see if i can fix this to a shift register 🙂

0 Kudos
Message 9 of 19
(7,694 Views)

Here is the LV15 version of the one I posted a few messages ago.

0 Kudos
Message 10 of 19
(7,689 Views)