If all the windws are FileMaker windows, not windows from other applications:
ValueCount ( windowNames )
So i've been asked to provide a button on our invoice layout to open a duplicate window for the purpose of looking up a different invoice and being able to compare the two side by side. That's no problem. My concern is being able to script for closing the correct window and not ending up with hidden windows behind the main window. I know the users will close the window using the close window "X" even if I provide a close button. Can I fire a script when a window is closed in this way? And would you have any suggestions as to the logic to compare the windows and for instance if the user is trying to close the main window, have the script either switch names to make the remaining window the main window or switch windows and close the compare window instead? What would you suggest?
Clicking the x closes the window just like a button with close window does.
Unless you use a script to specifically rename the original window, Get ( FileName ) = Get ( WindowName ) will be true for the original window and not the secondary window.
I'd be inclined to make the second window "modal". meaning that the user cannot interact with other windows, nor lose it behind them until the window is closed by clicking the x or a close button on the layout.
If you want to do that, use a paused infinite loop in the script that opens the window:
Then the last step of your close window script should be "Halt Script" to terminate this paused script after closing the window. With custom menus in FileMaker advanced, you can set up the menu option for close window to run the same script and then the X button will also run this script.
When using this the user would need to be able to perform finds or run a script for finding an invoice by it's invoice number or even change layouts to view more information. I don't believe that can be done using the "modal option". So I guess it's time to learn how to use custom menues :)
Got it. Thanks Phil :)