From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to put a Stop Button in a non Global Front Panel?

I'm using a global Stop button to stop two While loops and close the file they are both writing to.  I want the .exe that I will eventually release not to have the Stop button floating in the Global VI Front Panel.  This does not look professional to me.  I would like to put just the global Stop button alone, without the menu bar, elevator, etc., into my Front Panel.  What I have right now is shown below.

 

StopButtonAndMainFrontPanel.png

0 Kudos
Message 1 of 6
(2,667 Views)

If you are using an event structure, use the VI->Panel Close? event.  That's right, just let the user close the window like they do for another other application.  You key off of that even and set your global variable to TRUE and stop your other loops.


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
Message 2 of 6
(2,662 Views)

I am not using Event structures, and have not used them yet, although I was introduced to them in an online Cores.  I did look into how I could use an event structure for my application, but it seems problematic. I have tasks reading from devices.  Every 100 [ms][ the While empties out the DAQmx read buffer and does a number of other things.  If I wrap the guts of the While loop in an Event structure, it won't run unless the Even structure sees a valid event.  Also, I want to be sure that pressing a Stop button "instantly" stops both While loops and closes the output file.

 

Lastly, since the program will run a long time, hours, I keep some statistics of how many samples were read before it stopped.  Hitting the close window "X" will wipe everything out.

 

OK.  I may just leave the big Stop button as is but still use an Event structure to handle any shutdown issues, like possibly writing the stats to a file.   

 

Anyway, thanks for the response.  Expect an increment in your Kudo counter.:smileyhappy

0 Kudos
Message 3 of 6
(2,615 Views)
Using a global in a single VI makes no sense. Globals would be used in multiple VIs (if used at all). Replace your read of the global with a read of a front panel Boolean. Do you have multiple reads of it?
0 Kudos
Message 4 of 6
(2,608 Views)

If I put a Front panel Stop using local variables to stop the Whiles and to close the file, the file will get closed before the While and generate an error. Also, in an effort to clean up the diagram,  code that  constructs unique file names is consolidated into a single SubVi.   

0 Kudos
Message 5 of 6
(2,598 Views)
You have not posted any code do any discussion of whiles, files, or errors, is pretty meaningless.
0 Kudos
Message 6 of 6
(2,592 Views)