Jump to content




Get count of Open Windows


This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1 OFFLINE   chrisk1  newbie

chrisk1
  • Members
  • 19 posts
  • :

Posted 08 November 2006 - 02:42 PM

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

#2 OFFLINE   comment  consultant

comment
  • Members
  • 21,137 posts
  • Time Online: 187d 10h 40m 8s

Posted 08 November 2006 - 02:54 PM

Try:

ValueCount ( WindowNames ( Get (FileName) ) )

#3 OFFLINE   ThatOneGuy  apprentice

ThatOneGuy
  • Members
  • 172 posts
  • :

Posted 08 November 2006 - 04:10 PM

Hi CK:

Quote

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

#4 OFFLINE   LaRetta   Lifetime Student

LaRetta
  • Members
  • 8,061 posts
  • Time Online: 57d 23h 32m 6s

Posted 08 November 2006 - 08:35 PM

Quote

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

  :jester:    :jester:  

LaRetta
Each assumption is an educated guess, a likely condition or event, presumed known and true in the absence of absolute certainty.

#5 OFFLINE   Inky Phil  Loose cannon

Inky Phil
  • Members
  • 1,072 posts
  • Time Online: 5h 19m 38s

Posted 09 November 2006 - 12:32 AM

Quote

Always.

LMAO
I thought ' With what I know now I think I should start again' - so I did.

With what I know now...............

#6 OFFLINE   ThatOneGuy  apprentice

ThatOneGuy
  • Members
  • 172 posts
  • :

Posted 09 November 2006 - 06:02 AM

Quote

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:

#7 OFFLINE   chrisk1  newbie

chrisk1
  • Members
  • 19 posts
  • :

Posted 09 November 2006 - 08:28 AM

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

#8 OFFLINE   MCM  newbie

MCM
  • Members
  • PipPip
  • 2 posts
  • :

Posted 07 February 2009 - 12:03 PM

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

#9 OFFLINE   comment  consultant

comment
  • Members
  • 21,137 posts
  • Time Online: 187d 10h 40m 8s

Posted 07 February 2009 - 12:07 PM

I am not sure what you mean by "this".

#10 OFFLINE   MCM  newbie

MCM
  • Members
  • PipPip
  • 2 posts
  • :

Posted 07 February 2009 - 12:13 PM

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

#11 OFFLINE   comment  consultant

comment
  • Members
  • 21,137 posts
  • Time Online: 187d 10h 40m 8s

Posted 07 February 2009 - 01:18 PM

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/...php?tid/200643/


Back to Layouts


FMForum Advertisers