Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4653 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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?

Posted

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.

Posted

Yes, that seems to be the assumption that many developers* have: that THEIR database is the only one the user will have open. :D

* Present company excepted, naturally.

Posted

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.

Posted

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

Posted

Yes the trick is to leave the last window open, exit the loop, then close the window. :D

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.