LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Preventing A Section of Code Within A While Loop From Running

Hey gang! I've coded myself into a corner and am looking for a way out. The "Auto Barrel" local variable has information written to it earlier in the case structure and that information is passed out of the event structure once the while loop that contains it ends. This is normally an excellent thing. However, my problem is that I have added a "cancel" button to the program that once pressed, has a confirmation dialogue asking the user if they are certain they don't want to add a barrel. My problem is that even if "Yes" is pressed, the while loop still ends up passing the information contained in Auto Barrel on which, in this program, means that the cancel button doesn't actually cancel anything as the information is already in "Auto Barrel" and is passed on once the cancel button ends the loop.
 
 
I am fully aware that this code is doing exactly what it should do, but how can I get the cancel button to keep "Auto Barrel" from passing the information along? This section of code is run more than once and all of my solutions so far work for one interation, then it fail. Thanks folks for helping me out of my pickle! And Happy Pi Day to my fellow geeks!
 
-- Jason
 
 
0 Kudos
Message 1 of 9
(3,356 Views)
Hmmm, hard to tell without seeing the VI. To many hidden wires, cases that are not visible, backwards wires, overlapping objects, etc. Why are you chopping up all dataflow and use local variables? Event structures should not contain loops that potentially run for a long time, blocking everything else.
 
In any case, the lower case structure ALWAYS executes after the event structure, so there are many solutions:
  • If canceled, create a special cluster containing "no barrel" as Barrel ID and create an empty case for that below.
  • Incorporate the case structure in the event structure
  • etc.
Attach the VI for more detailed help.
0 Kudos
Message 2 of 9
(3,349 Views)
Thanks Altenbach! I spent 20 minutes trying to come up with the best way to explain the problem so I understand how confusing it must look. Heck, I coded it and it's still confusing to me. I attached the complete VI. The goal is to be able to add a new barrel at any time, with only one of each type going at a time. So I could say, launch a tin barrel, followed 20 minutes later by a zinc barrel, and then launch another tin barrel once the first one is complete. The loop and local variable craziness is the only way I have able to get things to work. I fully understand the VI is most likely a textbook of bad programming examples, but it is my first LabVIEW attempt and I'm doing everything I can to increase my LabVIEW knowledge on a daily basis.
 
So I am honored to receive any tips, pointers, and criticism!
 
-- Jason
0 Kudos
Message 3 of 9
(3,338 Views)

Also I did try the "no barrel" cluster idea but I could not get it to work. I branched off the "not equal to 3" comparison and had a case structure. If the case structure equaled 3, it would pass the "non-existent" data along, otherwise it passed on the actual information in "Auto Barrel" but everytime I would expect "No Barrel" to be loaded into the cluster, it would be the process and size that I had selected before hitting cancel.

Very, very baffling.

-- Jason

0 Kudos
Message 4 of 9
(3,324 Views)

Jason:

I did not find the "Cancel" button you are referring to. Please point me to it in the code.

Thanks,

Rudi N.

0 Kudos
Message 5 of 9
(3,301 Views)
Sorry! I definately should have pointed that out. If you run "Main Barrel Automation.vi" and click "Add Automated Barrel" a little "add barrel wizard" runs that let's you select a process type and a barrel size. Once these values have been selected, the cancel button on the bottom of the popup window is useless because the program has already obtained the values and they are passed on once the loop has ended.
 
-- Jason
0 Kudos
Message 6 of 9
(3,298 Views)
Jason:
 
Are you still experiencing issues with your code? Please let me know.
Thanks,
 
Rudi N. 
0 Kudos
Message 7 of 9
(3,240 Views)

Hey Rudi! I think I have it under control now thanks for checking! There are some pros on here, I'll tell you what...

 

-- Jason

0 Kudos
Message 8 of 9
(3,228 Views)

Jason:

That's great to hear Smiley Happy

Thanks,

Rudi N.

0 Kudos
Message 9 of 9
(3,208 Views)