Jump to content

How to stop a file from closing?


This topic is 5706 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I made a script to run on closing that asks the user to confirm before closing. If they click cancel, I want the file to stay open (I used the 'exit script' step unsuccessfully). If they click cancel it closes anyway. How can I stop it from closing if they click cancel.

Phil

Link to comment
Share on other sites

Here's some help from the FM online help system

Get(LastMessageChoice) function

Format

Get(LastMessageChoice)

Parameter

None

Data type returned

number

Description

Returns a number corresponding to the button clicked in an alert message that is displayed by the Show Custom Dialog script step.

Returns:

1 for the first button (by default, labeled OK)

2 for the second button (by default, labeled Cancel)

Link to comment
Share on other sites

That's a bit tricky. The close button is very severe.

The closest I've come to is this example, which on closing the main file opens a second "reopener" file. The "reopener" prompts the user asking if they want to close or not. If they say no, the "reopener" does what the file name suggests and reopens the main file.

In the 'close' script of the main file you'd probably want before closing to "save" certain things (eg current record, current layout) which you could then go back to with an "open" script called by the reopener. This would give the user the impression they hadn't closed at all.

close_dialog_example.zip

Link to comment
Share on other sites

Thanks ideal. I was using a Get(LastMessageChoice) but that wasn't the part that didn't work. See below James has answered the Q.

Many thanks,

Phil

Link to comment
Share on other sites

Thanks Stuart that works even better (in your file) as no second file is needed.

I imported the script but didn't know what the custom menu thingy was all about or how it worked. Clearly it's important since the script didn't work in my file without it. No surprises there I suppose.

Phil

Link to comment
Share on other sites

Just a side note for others, this will not stop the window from closing when the user clicks the 'X' to exit the FM application on the WINDOWS platform though.

Link to comment
Share on other sites

This topic is 5706 days old. Please don't post here. Open a new topic instead.

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
 Share

×
×
  • Create New...

Important Information

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