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.

Scripting Windows Close

Featured Replies

Operating system - Windows. Is there a way to script the "x" (close window). I have many related files to a main window. Would like to be able to script the "x" on main window, if user clicks on "x" that all files close. I do not want users to access directly to related files. Currently have related files opened minimized. Does this make any sense???

In Document Preferences you can specify a Shutdown script; in the shutdown script you can make sure you close everything. Sounds easier than it is, though.

Some tips:

1) Closing a file that is not open will first open the file so that it can close it. But that can cause other stuff you already closed to re-open. So, use DatabaseNames to check if its open before closing it.

2) If a window becomes visible because of another one closing, it can invoke a refresh that will re-open files you closed. So, first hide all windows that are open (don't hide ones that aren't open... it will open them to hide them). Then, with everything hidden, start closing them.

  • Author

Thanks for including the tips --- Sounds exactly what I'm wanting. Will play around with it later today.

Using the DatabaseNames finction and IF conditionals in a script you can check if a file is open before issuing the close step. However this will break if the file names are ever changed.

Using the DatabaseNames finction and IF conditionals in a script you can check if a file is open before issuing the close step. However this will break if the file names are ever changed.

Yeah... but is there an alternative?

And besides, you probably have the same database name issue in getting a multi-file database started up properly. And then all the relationships die if the filenames change. And all the external script calls die if the filenames change. And since you can't use variables for any of those filenames, there is no way to build a system in FileMaker that's not brittle.

Or am I missing something?

Relationships etc are robust if the file names are changed with a tool like FM Developer -- it goes through and updates all the relationships and script references etc.

However the problem is that you'll be hard-coding the file's name into the IF calculation, and nothing can change this. One way to make the process easier could be to make a Pres file and store the file's name in a field in there. Make sure all references to the file's name in all calculations points to the Prefs file. Of course, comebody has to keep the name in the prefs file up to date, but at least it'll in one place not hidden throughout the solution.

Another other solution: open all files at startup, and close them all if any one is closed. An "all or nothing" scenario. I've tended to do this lately for single-user solutions where network speed isn't an issue.

Another possibility is to create a special value list called "FileID" in each file, and have it contain a single item that identifies the file as part of your solution. Eg., "LineItems", "Invoices" or "Customers".

Then, a script in your main file can get a list of all the databases with the DatabaseNames function and then check each to see which file it is with:

Valuelistitems(MiddleWords(DatabaseNames,gFileNo,1),"FileID")

where gFileNo is the number of the file you are checking.

If the function doesn't return anything, then the file is not part of your solution. Otherwise, it will return a text value independent of the actual file name identifying the file.

This is probably a lot of trouble unless you are changing your file names a lot.

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.