Wikisnoodle Posted February 26, 2012 Posted February 26, 2012 The following is supposed to look for and close any windows belonging to the open database when the main window is closed. I’m sure I’ve tested it successfully, but now it goes into a never-ending loop. Loop Exit Loop If [$WindowCount = 0] If [ValueCount (WindowNames (Get(FileName))) ≥ 1] Set Variable [$WindowCount; ValueCount (WindowNames (Get (FileName)))] Close Window [Current Window] End If End Loop If I make the third line: If [ValueCount (WindowNames (Get(FileName))) + 1 ≥ 1] it closes the frontmost window leaving any others open. If I create a field with the unstored calculation: ValueCount (WindowNames (Get(FileName))) I get ‘0’ Where am I going wrong? Is there a better way to do this?
Vaughan Posted February 26, 2012 Posted February 26, 2012 Use the loop to close all windows except for the last one. Then exit the loop and close that one as the final step. If all the windows are closed, the what file is the script running in? Why not just Quit? If there is more than one database (solution) open then quit will annoy the !@#$ out of the user because they have just been dumped back to the desktop, and they now have to go back and open all their other databases again. I use this loopy thing so that users can open as many windows as they want, but if they close the "main" window then all the other windows get closed too.
bcooney Posted February 27, 2012 Posted February 27, 2012 Well, there was no mention of another open database.
Vaughan Posted February 27, 2012 Posted February 27, 2012 Yes, that seems to be the assumption that many developers* have: that THEIR database is the only one the user will have open. * Present company excepted, naturally.
David Jondreau Posted February 27, 2012 Posted February 27, 2012 Loop Exit Loop If [$WindowCount = 0] If [ValueCount (WindowNames (Get(FileName))) ≥ 1] Set Variable [$WindowCount; ValueCount (WindowNames (Get (FileName)))] Close Window [Current Window] End If End Loop You're setting your $var before the Close Window. Switch the two steps and remove the uneccessary If[] statement.
Wikisnoodle Posted February 27, 2012 Author Posted February 27, 2012 Thanks for all contributions. As guessed, I can't use 'quit'. I combined the two suggestions and got there with... Loop Exit Loop If [$WindowCount = 1] Set Variable [$WindowCount; Value: ValueCount (WindowNames (Get (FileName)))] Close Window [Current Window] End Loop Close Window [Current Window] Cheers
Vaughan Posted February 27, 2012 Posted February 27, 2012 Yes the trick is to leave the last window open, exit the loop, then close the window. :D
David Jondreau Posted February 27, 2012 Posted February 27, 2012 I don't see why a simple: Loop Close Window End Loop wouldn't work.
Recommended Posts
This topic is 4653 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