LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exit LabView, clean up code.

Hello!

I'm about to finish my LabView application. I have some problems left and I need help to solve them.

My porgram uses some C++ code (which I call from the "Call Library Function Node"). In LabView I've made a sequence where in the first frame all C++ init code is executed, the second frame is the main program and the last frame is the exit and clean up code. The clean up code must execute or there will be ports open, memory leaks, etc. My problem is that if you stop the program from the LabView menu stop button, the program terminates before the last frame is executed. I would like to either remove the LabView stop button or, connect the stop button to my exit code somehow.

Follow up question: If I make an .exe (which is pos
sible right?) are the stop start, stop, debug, etc -buttons still there? Or can you make a "real" application that don't use the LabView buttons to start, stop, etc?

Thanks in advance,

/Thomas
0 Kudos
Message 1 of 4
(4,101 Views)
Hi Thomas,
the stop button (Abort) can be removed by going to the VI Properties for the .vi and going to the Window Appearance section. If you then select customise, you can see an option to "Show Abort button". Simply de-select this, and when you return to your .vi, it'll no longer be available.
If you make an executable of this .vi, it will have the same window layout as you have as a normal .vi, so work out if you need the Run button etc, and select / de-select them as necessary in the window appearance dialog.

Bear in mind that your code needs to be pretty solid on it's exit so that when you hit stop it does actually stop. Also worthwhile adding in the Quit labview .vi (under Application Control palette) so that when you've built an application, i
t will quit LabVIEW for you - beware that this will also work while you're developing, so be careful. I've attached a part sub.vi that shows how I normally implement this so that I don't quit if I'm developing.
Making a .exe requires either the PDS version of LabVIEW or the appropriate version of Application Builder which are available from your local NI or the web-site.

Hope that helps

S.
// it takes almost no time to rate an answer Smiley Wink
Message 2 of 4
(4,101 Views)
Tobe,

Of course you can remove the buttons.
Right click on the icon of your front panel and have a look at the
properties.


--
Roger Ohlund, MSc Engineering Physics
Ericsson AB
mailto:Roger.Ohlund@epl.ericsson.nospam.se
Spam countermeasures included.

Daytime Engineer
Lifetime Flyfisherman


"Tobe" wrote in message
news:5065000000080000006E5A0000-1027480788000@exchange.ni.com...
> Hello!
>
> I'm about to finish my LabView application. I have some problems left
> and I need help to solve them.
>
> My porgram uses some C++ code (which I call from the "Call Library
> Function Node"). In LabView I've made a sequence where in the first
> frame all C++ init code is executed, the second frame is the main
> program and the last frame is the exit and
clean up code. The clean up
> code must execute or there will be ports open, memory leaks, etc. My
> problem is that if you stop the program from the LabView menu stop
> button, the program terminates before the last frame is executed. I
> would like to either remove the LabView stop button or, connect the
> stop button to my exit code somehow.
>
> Follow up question: If I make an .exe (which is possible right?) are
> the stop start, stop, debug, etc -buttons still there? Or can you make
> a "real" application that don't use the LabView buttons to start,
> stop, etc?
>
> Thanks in advance,
>
> /Thomas
0 Kudos
Message 3 of 4
(4,101 Views)
Hi,


I don't know how it is done in C++, but in asssembler, a (windows) dll has a
DllEntry Proc. C++ shoud not be too different.

If the dll is loaded, this proc is called, with reason= DLL_PROCESS_ATTACH.
If the dll is removed from memory, DLL_PROCESS_DETACH is the reason.

If the DllEntry proc is called with reason= DLL_PROCESS_DETACH (when the dll
is removed, e.g. when labview is closed, or all the dll references are
removed from memory), a proper cleanup can be made.

Of cource, this does require keeping track of all things to clean up (memory
created by the dll, etc.).

This is kinda fun, because you can make popups when a dll is loaded. The vi
does not even need to be started. Or you can make the popup appear when the
user is done with the dll, even if no vi is running.

Btw. In LV6, you can capture the 'close' event, and close everything
properly. You can choose to close the window, or to ignore the close.

Btw2. You can remove the menu (or just the exit), so the user is not able to
close LV.

Regards,

Wiebe.



"Tobe" wrote in message
news:5065000000080000006E5A0000-1027480788000@exchange.ni.com...
> Hello!
>
> I'm about to finish my LabView application. I have some problems left
> and I need help to solve them.
>
> My porgram uses some C++ code (which I call from the "Call Library
> Function Node"). In LabView I've made a sequence where in the first
> frame all C++ init code is executed, the second frame is the main
> program and the last frame is the exit and clean up code. The clean up
> code must execute or there will be ports open, memory leaks, etc. My
> problem is that if you stop the program from the LabView menu stop
> button, the program terminates before the last frame is executed. I
> would like to either remove the LabView stop button or, connect the
> stop button to my exit code somehow.
>
> Follow up question: If I make an .exe (which is possible right?) are
> the stop start, stop, debug, etc -buttons still there? Or can you make
> a "real" application that don't use the LabView buttons to start,
> stop, etc?
>
> Thanks in advance,
>
> /Thomas
0 Kudos
Message 4 of 4
(4,101 Views)