yknot Posted March 2, 2007 Posted March 2, 2007 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
Genx Posted March 2, 2007 Posted March 2, 2007 (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 March 2, 2007 by Guest
yknot Posted March 3, 2007 Author Posted March 3, 2007 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
Genx Posted March 3, 2007 Posted March 3, 2007 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.
RodSierra Posted March 3, 2007 Posted March 3, 2007 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 ) ]
Genx Posted March 3, 2007 Posted March 3, 2007 But that just closes every window except for one... And then sets it to a default location, i suppose it might be suitable but...
LaRetta Posted March 3, 2007 Posted March 3, 2007 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. LaRetta
Genx Posted March 3, 2007 Posted March 3, 2007 Lol, or just don't use them I build single window solutions.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now