Jump to content
Sign in to follow this  
David Graham

Prevent accidental exit (FM10 only)

Recommended Posts

The new FM 10 events are getting a lot of press, but there's one event that we've always had that just got a tiny bit more powerful. The OnLastWindowClose event is the event which has always triggered the script you've selected to run when closing the file. In FM 10, this event has now been modified to run the script prior to the event, which means that you can now ask the user if they really want to quit the database. If you return an Exit Script [result=false] step then it wont execute the close command on the last window for that file.

Edited by Guest

Share this post


Link to post
Share on other sites

Good to know. I haven't come across this yet as I have used a custom menu for exiting the application.

Share this post


Link to post
Share on other sites

Hi David

Ok, this is interesting but is it praticable ?

Let say that I have this script to run when closing the file to prevent accidental closing with the windows's X :

Show Custom Dialog [ "You can't close this file in this way" with OK ]

Exit Script [ Result: 0 ]

End If

How can I modify that script to allow the user to close the file ONLY with a button on the layout ?

This, for example assigning 1 to the script parameter of the button, do not work:

If [ Get ( ScriptParameter ) ]

Close File

Else

Show Custom Dialog [ "You can't close this file in this way" with OK ]

Exit Script [ Result: 0 ]

End If

The problem is that I can't write anymore the script step "Close File", otherwise the script will fire another time ( and w/o the script parameter ).

Share this post


Link to post
Share on other sites

AFAIK, all you have to do is return a true exit script and the triggering event (close last window) will continue.

If [ Get ( ScriptParameter ) ]

Exit Script [ Result: 1 ]

Else

Show Custom Dialog [ "You can't close this file in this way" with OK ]

Exit Script [ Result: 0 ]

End If

Share this post


Link to post
Share on other sites

AFAIK, all you have to do is return a true exit script and the triggering event (close last window) will continue.

But where is the "Close File" step ?

We aren't closing with the close command, but with a button on the layout that fires this script.

Share this post


Link to post
Share on other sites

I don't want to spoil it for you - I am sure you can figure this out. :

http://www.screencast.com/t/XHw9WDyXB

Share this post


Link to post
Share on other sites

Yes, your ControlledClose10.fp7 do exactly what I am NOT ( still ) able to do.

Searching... :

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.