Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

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???

Posted

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.

Posted

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.

Posted

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?

Posted

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.

Posted

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.

This topic is 8073 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
×
×
  • Create New...

Important Information

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