chrisk1 Posted November 8, 2006 Posted November 8, 2006 Is there a way to get a count of the number of windows that a certain database has open at any time? Long story short—my users keep on exiting the database by closing windows (using close buttons I've created) and need to log back in, which they get tired of quickly. I tried a script to let them know when they are about to exit the db, and not just a window, and set it to run when the db closes through file options. But when the cancel option is selected to stay in the db, it closes out anyway, I'm guessing because technically the file is closing and nothing can stop it. I'd like to be able get an open window count and test that when they hit my close buttons, so if the window count is 1 when they close it gives them the option to cancel and stay in if they want. I haven't been able to find anything that will return this value in the lists of functions. Thanks! — CK
comment Posted November 8, 2006 Posted November 8, 2006 Try: ValueCount ( WindowNames ( Get (FileName) ) )
ThatOneGuy Posted November 9, 2006 Posted November 9, 2006 Hi CK: ... But when the cancel option is selected to stay in the db, it closes out anyway, I'm guessing because technically the file is closing and nothing can stop it. Yeah, that's burned me before. Hmmm ... well, I experimented some time back with the Design function named WindowNames {( fileName )}, but any successes were modest, at best. Per a portion of FM's onlline help ... "The WindowNames function returns a list of the names of windows that are currently open. Use the optional fileName parameter to only return windows that are based on the specified file. The window could be visible, hidden, or minimized. The order of the names in the list matches the current stacking order of the windows. The visible windows are listed first, then the minimized windows, then the hidden windows. If there are no databases or windows open, an empty string is returned." * Seems a script could test whether "value count > 1" ... allowing for the one window that hopefully is still open. If multiple windows are open, the script could have a Select Window step, using any of those values in the list to go to a window by its name, specified through the calculated option. I think. All that being said, I can't tell you how it might behave in a multi-user environment, but I'd clearly be interested to know what you find. ------- * ... and where might that empty string be displayed when there are no databases or windows open?... I'd like to see that. Perhaps an existentialist might say it's always there whenever FileMaker is not running. ... then what about if a man is standing in the middle of the forest speaking, and there is no woman around to hear him, is he still wrong?
LaRetta Posted November 9, 2006 Posted November 9, 2006 ... then what about if a man is standing in the middle of the forest speaking, and there is no woman around to hear him, is he still wrong? Always. And you were wrong to ask the question. LaRetta
ThatOneGuy Posted November 9, 2006 Posted November 9, 2006 Always. And you were wrong to ask the question. Yeah, I should have known that as soon as I typed the question and clicked "Add Post" ... but a guy can still dream, can't he? :dreaming:
chrisk1 Posted November 9, 2006 Author Posted November 9, 2006 Thanks, all! Value count of window names did the trick! This also solves a few other related problems I've been hesitant to bug people with. Hopefully someday I can be as helpful as yall have been to me. Thanks again — CK
Newbies MCM Posted February 7, 2009 Newbies Posted February 7, 2009 Is there a way to make this work in FMP 10 even if a user closes a window with the OS (not with a scripted button)?
Newbies MCM Posted February 7, 2009 Newbies Posted February 7, 2009 Sorry - here is a synopsis: Is there a way to get a count of the number of windows that a certain database has open at any time? Long story short—my users keep on exiting the database by closing windows (using close buttons I've created) and need to log back in, which they get tired of quickly. I tried a script to let them know when they are about to exit the db, and not just a window, and set it to run when the db closes through file options. But when the cancel option is selected to stay in the db, it closes out anyway, I'm guessing because technically the file is closing and nothing can stop it. I'd like to be able get an open window count and test that when they hit my close buttons, so if the window count is 1 when they close it gives them the option to cancel and stay in if they want. I haven't been able to find anything that will return this value in the lists of functions. Thanks! — CK Try: ValueCount ( WindowNames ( Get (FileName) ) ) Is there a way to make this work in FMP 10 even if a user closes a window with the OS (not with a scripted button)?
comment Posted February 7, 2009 Posted February 7, 2009 There is a way to make this work in previous versions, as well as in version 10 - but you need to use a custom menu set that replaces the File > Close command by a script, e.g. If [ ValueCount ( WindowNames ( Get (FileName) ) ) = 1 ] Show Custom Dialog [ Message: "Are you sure?"; Buttons: “OK”, “Cancel” ] If [ Get ( LastMessageChoice ) = 1 ] Close File [ Current File ] End If Else Close Window [ Current Window ] End If In version 10, you can PREVENT users from closing the last window - see: http://fmforums.com/forum/showtopic.php?tid/200643/
Recommended Posts
This topic is 5768 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 accountSign in
Already have an account? Sign in here.
Sign In Now