February 26, 201213 yr 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?
February 26, 201213 yr 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.
February 27, 201213 yr 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.
February 27, 201213 yr 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.
February 27, 201213 yr Author 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
February 27, 201213 yr Yes the trick is to leave the last window open, exit the loop, then close the window. :D
Create an account or sign in to comment