LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

doing stuff after quiting with "x" in window question.

Hello :),
 
I often use an event-structure in a while-loop, as main structure for my programs.
If the user stops the program by pressing the "x" in the window, the program immediately
terminates.
 
What I want is, when the user presses "x", some code is run before terminating the application.
 
Things like IMAQ Dispose, to free memory or a VI that shuts down a machine drivin with ActiveX.
What would be great is when the program would save a configurationfile (I know how to do this,
but not how to do it immediately after pressen the "x".).
 
Hope you can help me!
Thx!
 
 
--------------------------------
The Enrichment Center is required to remind you that you will be baked, and then there will be cake.

0 Kudos
Message 1 of 7
(3,514 Views)
Hi Heinen,

catch the "window close" event in your event structure - now you can do anything you want, even avoid closing the window or quitting the vi Smiley Wink


Message Edited by GerdW on 03-18-2008 12:10 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(3,506 Views)
To quote Ed Dickens
"Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences."

In VI properties > Window appearance, disable the abort button, and place a stop button on your front panel.  You can execute your houskeeping processes and quit the VI when this button is pressed.
Jim

LV 2020
Message 3 of 7
(3,503 Views)
Hi...
 
you can do it this way.. add an event "Panel Close" under "This VI" event source. Place your codes in this event.
 
See the diagram
Message 4 of 7
(3,501 Views)
Thanks GerdW and vsh, if I keep hanging out here I may finally learn what I'm doing! Smiley Wink
Jim

LV 2020
0 Kudos
Message 5 of 7
(3,495 Views)

Wow, this is great!!!!

 

Thank you very much for all your quick responses!

 

Robot Very Happy

 

--------------------------------
The Enrichment Center is required to remind you that you will be baked, and then there will be cake.

0 Kudos
Message 6 of 7
(3,478 Views)

I like to use a state machine where the 'panel close?' event filter is handled and the next state is a state called 'exit?'  In this state the the user is asked if they intend to exit the program.  if yes then shutdown code is execoted and the vi finished normally if no wh have filtered the close panel event and continue normal operations.  The close panel is fine to use it is not an abort vi call  by any means.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 7 of 7
(3,470 Views)