Example Code

Safeguard Against Unintentional Panel Closes

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

Code that will double check if the user really wants to close the application after pressing the red close button on the front panel.

 

Description

In LabVIEW, you can take advantage of Filter Events to catch things (and undo if desired) before they happen. In LabVIEW, there are Filter Events and Notify Events. When configuring the event structure, Notify Events show up with a green arrow next to them. These events simply tell you that the desired event occurred - nothing more. Filter Events show up with a red arrow next to them, as well as a question mark. Filter Events let you know about the event before it is actually processed. That way, you have the option to override.
Download and run the attached code. If you try and close the VI while it is running by clicking the Red "X," you will get a verification dialog. This can be used as a safeguard in critical applications.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Run the VI
2. Press the red close button
3. When prompted, select the desired option
4. Use the Stop button to finish the execution.

 

Additional Information or References

Snippet.png

Wes Pierce
Principal Engineer
Pierce Controls

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Vladiator
Member
Member
on

Could you convert the code to LV 2009 please? Thanks!

Wes_P
Member
Member
on

There you go.

Wes Pierce
Principal Engineer
Pierce Controls
Vladiator
Member
Member
on

Thank you! I am having this discussion on the NI forum. Basically I am trying to porperly close the front panel so it can be re-opened again. The suggestion is to use FP.Close event to properly close the fron panel - it might be also useful in your example.