Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Prevent a script from running in the wrong window

Featured Replies

I have just discovered that with FM 8.5, if you are running a script in a window and you click on a different FM window the script starts running in the other window.

Can some one help me to solve this behaviour?

Edited by Guest

what is the script your running...

this is an interesting issue.

Stuart almost said it, but why not just Post a copy of your script.

Lee

  • Author

Any script that lasts some time to finish. Imagine any loop stablishing a field in a table with 2000 records. If you have two windows open, if you are running the script in the first window and accidentally do a click in the second window, the script will start running in the second window.

Freze window

loop

set field X

go to next record

end loop

Refresh window.

  • 3 weeks later...
  • Author

Hi again, did someone find any reason for this behaviour?? or how to solve it??

Set Variable[ $window ; Get ( WindowName ) ]

Freeze window

loop

set field X

go to next record; exit after last

If[ Get(WindowName) <> $window ]

Select Window[ Name: $window ; CurrentFile]

If[ Get(LastError) <> 0 ]

Show Custom Dialog[ Error ; Window Closed ]

Exit Script[Window closed]'

End If

End If

End If

end loop

Refresh window.

  • Author

Thaks for your answer Genks!

That will help but wont ensure you do things in the proper window. You can have two windows with the same name and same fileds, so you wont get any error as far as know.

This wont happen with FM 7 and you dont need to control that error. In my opinion this behaviour is useless and or badly implemented (¿a bug?) ¡How can cause an error just a user clicking in the wrong window?!!

I am a little bit depressed with this issue as I wont be able to move my solution to fm8.5 until I add this error check to every process.

Can someone show me any practical use for this behaviour or something to forbid the user to go to another window while a script is running?

Fortes:

A bit tricky; FreezeWindow[] doesn't seem to work as well as it used to in the .fp5 days. Best bet would be to implement the kind of check Genx suggested, along with a strict policy of window naming - or even NOT window naming, as FileMaker will append a number when a duplicate window is opened, unless you've specified a name.

You could also (when running a long loop like that) hide other windows and move to a layout showing a message like "Operation in Progress, Do Not Disturb" for the duration of the loop. Once the loop is done, you could return the hidden windows to the user.

Other than that, I'm not sure what can be done.

-Stanley

  • Author

Thanks for your suggestions.

I really appreciate your ideas.

Anyway, it looks that this will cost me a lot of hours reviewing my code.

This effort would be worthy just if I could see any benefit on this new behaviour.

Is there any chance that this can be fixed in any new update???

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.