LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing Serial Port on Stop/Abort

Wish I was there...heh

Cason Clagg
SwRI
LabView 7.1, Windows XP
0 Kudos
Message 11 of 16
(1,106 Views)
Is there a way to execute LV code on exit? By exit I mean when someone pushes the X button windows has in the bar?

Cason Clagg
SwRI
LabView 7.1, Windows XP
0 Kudos
Message 12 of 16
(1,095 Views)
I'm sorry I can't find the link to the particular thread, but someone asked that question as an aside in another thread. The answer was along the lines of (it wasn't me who answered it) have the user exit the window using a stop button, and don't make that X available to them, that way you can control what happens on a click.

Geoff
0 Kudos
Message 13 of 16
(1,089 Views)
Again, the answer is an event structure. One of the events you can capture is Application Exit. Look at the shipping example called Event Conditional Stop. It has an event for the front panel stop button, clicking the X button/File>Exit, and File>Close.
Message 14 of 16
(1,083 Views)
Thanks Dennis, I never knew the Event Structure's Close Panel event was tied to Windows' X button. Now no more hiding the X from users while making them hunt for some "special" Exit button.
Richard






0 Kudos
Message 15 of 16
(1,071 Views)

@Dennis Knutson wrote:
Again, the answer is an event structure. One of the events you can capture is Application Exit. Look at the shipping example called Event Conditional Stop. It has an event for the front panel stop button, clicking the X button/File>Exit, and File>Close.




There was actually also a way to do that before the event structure. It was a little bit more involved. You basically opened a VI reference to its own VI as one of the first things in a GUI VI and stored that reference in a loop. Then in your state machine idle polling you also polled the Front Panel.Open property through this VI reference. If that property went FALSE this meant the user had selected the little X in the top right corner (or System Menu->Close). Since you still had a VI reference open to the VI it didn't abort and you could push an "exit" operation on the state machine queue (including maybe a dialog box "Do you really want to quit the application?" 😉 to clean up whatever needed to be cleaned up, after which you left the state machine loop and as last thing closed the VI reference which closed the VI definitely.

Rolf Kalbermatter

Message Edited by rolfk on 06-28-2005 06:38 PM

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 16 of 16
(1,061 Views)