03-28-2017 08:36 AM
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.
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
03-28-2017 08:46 AM
Maybe I need to explaine myself a little better. The below picture is a part of my code.
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
03-28-2017 09:29 AM
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.
03-28-2017 09:42 AM
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.
03-28-2017 09:47 AM
I created local variables with this it seems i can do stuff with the array inside the if structure.
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.
03-28-2017 09:54 AM
Like this.
03-28-2017 09:57 AM - edited 03-28-2017 09:59 AM
@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.
03-28-2017 09:57 AM
I cant open your solution yours is written with 2016 and I have 2015. But I appreciate your help a lot 🙂
03-28-2017 10:02 AM
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 🙂
03-28-2017 10:07 AM
Here is the LV15 version of the one I posted a few messages ago.