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

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

Recommended Posts

Posted

I always end up with too many open windows and would like to write a script which would close all but the same two windows.

I have been trying to use the window names returned by the windownames function as variable to do a loop which would close one window after the other except the two I want open. I can't figure out how to assign the result of the windownames function as a variable.

The variable should then be assigned to the SelectWindow function.

Thanks for any help

yknot

Posted (edited)

Try this, it's a bit messy but...

Allow User Abort[off]

Set Error Capture[on]

Freeze Window

SetVariable[ $n ; 2 ]

SetVariable[ $windows ; Substitute( ¶ & WindowNames & ¶ ; ["¶The Window You want kept open here¶" ; ¶ ] ; ["¶The Second Window You want kept open here¶" ; ¶]) ]

Loop

Exit Loop If[ $n > valueCount($windows) ]

Select Window[ Name: GetValue( $windows ; $n ) ; CurrentFile ]

If[ Get(LastError) = 0 ]

Close Window

End If

SetVariable[ $n ; $n + 1 ]

End Loop

Edited by Guest
Posted

Tnx for the quick reply. Have not had a chance to write the script yet but would much appreciate a bit of explanation of this line:

SetVariable[ $windows ; Substitute( ¶ & WindowNames & ¶ ; ["¶The Window You want kept open here¶" ; ¶ ] ; ["¶The Second Window You want kept open here¶" ; ¶]) ]

yknot

Posted

SetVariable[ $windows ; Substitute( ¶ & WindowNames & ¶ ; ["¶The Window You want kept open here¶" ; ¶ ] ; ["¶The Second Window You want kept open here¶" ; ¶]) ]

Your don't want to close two particular windows so we're eliminating them from the list of windows to close.

Posted

A bit different approach I've used, in a script:

Loop

Exit Loop If [ ValueCount ( WindowNames ( Get ( FileName ) ) ) = 1 ]

Close Window [ Current Window ]

End Loop

Go to Layout [ “MyHome” ]

Set Window Title [ Current Window; New Title: Get ( LayoutName ) ]

Posted

But that just closes every window except for one... And then sets it to a default location, i suppose it might be suitable but...

Posted

I find it easier to clean up after myself after each layout/window switch. If this isn't tracked, you can run into 1) record lock issues and 2) system running out of resources and freezing up. You can use the same windows ... just perform layout switches. You can even rename your windows to the other window you are replacing/closing, thus switching horses mid-stream. You can test if a window is open and just bring it to the front if so; as compared to always opening a new one.

So the best defense is a good offense - consider tracking them to begin with. :wink2:

LaRetta

This topic is 6476 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.