LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple example of Panel Close? in Event Structure not working - please advise

Solved!
Go to solution

I am trying to implement a simple Close Panel intercept.   In the attached LabVIEW 2010 VI, I expect to see a dialog box saying "Now closing [filename]" which will then stop the VI but NOT close the panel.

 

Instead, I see the program run in Highlight Execution mode up to the While Loop,then,  when I press the Windows Close Window Button (X) in the upper right corner of the Front Panel window, both program windows immediately close.

 

Can someone tell me why this Discard? is not working?

0 Kudos
Message 1 of 10
(15,589 Views)

I'm not sure but I'll take a stab at it.  The name of the event is VI Ref Array.  You are discarding the Panel Close event for the array, not for the VI itself.  Is this supposed to work like you expect it to?

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 10
(15,575 Views)

 


@tbob wrote:

I'm not sure but I'll take a stab at it.  The name of the event is VI Ref Array.  You are discarding the Panel Close event for the array, not for the VI itself.  Is this supposed to work like you expect it to?


 

To build on that, is VI Ref Array a single reference or an array of references?

You would want to index out a single VI reference for this to work as expected.

Cory K
0 Kudos
Message 3 of 10
(15,571 Views)

How does the 'VI Ref Array' get the VIs to be 'controlled'?

I don't see the control linked to a terminal, and the registration is only done before the VI is started.

 

Here's a small VI that works as I would expect:

The only thing I adjusted in the VI is to connect the control to a terminal on it's connector pane.

One thing to mention your VI will stop after one FP.closing action.

 

Another question, why is there a second while loop inside the outer while loop?

I would use the OpenG wait with error VIs to have a dependent timeout.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 10
(15,546 Views)

I cobbled together the example by stripping down some much more complicated examples.  I am trying to get at the basic principles, which I obviously do not understand.

 

I really didn't intend to reference a VI Array; I just can't figure out how to reference the current VI.  It is not clear how I get the dynamic element I want to appear on the left side of the Event Structure.

 

That "inner loop" is a single frame of a stacked sequence.  Again, not my idea, seemed like it was involved in closing the reference.

 

I know I should be referencing "this VI" but neither the LabVIEW Help nor what I find on the Web shows me how to do that.

 

I'm not sure what TCPlomp is suggesting.  I don't really want to control anything but the current VI, certainly not AllVIs.  I don't know what the lower case e function represents.  (It's a BIG help if you can turn on labels for these low-component-count examples before capturing as an image.)

 

So, what I want to do is intercept the Windows Close command, and send out a Boolean True to trigger my shutdown procedures.

 

A better example should not be hard to find, since this is a really bad example.

0 Kudos
Message 5 of 10
(15,521 Views)
Solution
Accepted by mistercat

OK, this version works as expected.  I was able to find the "this VI" reference under Programming VIs and Functions - Application Control VIs and Functions - VI Server Reference.  (Not easy to find using LabVIEW help.  I actually copied it from another VI.)

 

It does display the "Now closing [filename]" message then puts out a Boolean True to stop the file loop.

 

Thanks to those who pointed out I was referencing an array of VIs rather than a single VI.

 

I believe this is the kind of very, very simple example that one should be able to find when searching for ways to override the Windows File Close function.

0 Kudos
Message 6 of 10
(15,511 Views)

Do you need to use a Dynamic Event?  Is there a time when you don't want to intercept the panel close event?  If not, then you don't need a dynamic event and you can simply use the This VI: Panel Close? event.  This would be a lot simpler than using a reference and registering it as a dynamic event.

 

Example_VI_BD.png

 

- tbob

Inventor of the WORM Global
Message 7 of 10
(15,505 Views)

 


@mistercat wrote:

Thanks to those who pointed out I was referencing an array of VIs rather than a single VI.


 

Just to be clear, you use an array of VI references for this event type (Front Panel.close?).

 

Good you solved your issue!

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 8 of 10
(15,496 Views)

Dear Sir, 

 

 

I have design code for Event structute but it is not working properlly ... Please suggest where is the problem

 

Download All
0 Kudos
Message 9 of 10
(10,106 Views)

Rahul, this thread is 5 years old. I would suggest making a new topic with your specific problem. Please include more information about what you are trying to do as well.

Please include a Snippet of your code, or attach your VIs, so that we can better assist you. We are here to help, but won't spend all day recreating your code from scratch.

 

Edit: New topic can be found here.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 10 of 10
(10,097 Views)