6 Replies Latest reply on Apr 13, 2009 5:46 PM by CountryBoy1

    Is Window Closed ?

    CountryBoy1

      Title

      Is Window Closed ?

      Post

      Is there a way to tell (with Script) if a window has been closed ?  I have two or more

      windows that have related tables and they need to be open.  If a user accidently closes

      one of them, can it be detected ?  Thanks for your help.  CountryBoy1

       

        • 1. Re: Is Window Closed ?
          marcusedward
            

          Here is the script I use for this situation (I also use two windows that need to be open)

           

          If [PatternCount (windownames (get (filename)); "your window name" ) = 0]

          New Window [name: "your windown name" ; height; xxx; width; xxx; top; xxx; left; xxx]

           

          from here you just need to show or hide status area and goto the desired layout

           

          Hope this helps,

           

          Marcus 

          • 2. Re: Is Window Closed ?
            CountryBoy1
              

            Dear Marcus:                                April 10th, 2009

             

               Just tried your code and it works well.  Have marked

             your reply as the solution.  Thanks much.

             

            • 3. Re: Is Window Closed ?
              philmodjunk
                

              Be sure to keep your window names distinct.

               

              If, for example, you have one window named "Widgets" and another named "All Widgets", you won't be able to use this method to check to see if the Widgets window is open. :smileywink:

              • 4. Re: Is Window Closed ?
                CountryBoy1
                  

                Dear PhilModJunk:

                           Thanks for your reply.  Not sure what you mean.  I've got a

                  "Window 1" and a "Window 2" and the code seems to know when

                  they are closed.

                 

                           Sincerely, CountryBoy1

                 

                • 5. Re: Is Window Closed ?
                  philmodjunk
                      

                  CountryBoy1 wrote:

                  Dear PhilModJunk:

                             Thanks for your reply.  Not sure what you mean.  I've got a

                    "Window 1" and a "Window 2" and the code seems to know when

                    they are closed.


                   

                  It's unlikely that you will have a problem with using Pattern count to search list of open windows, but it's a good idea to keep in mind that Pattern count does have a limitation to look out for when choosing names for your windows if you are going to use this technique to test to see if a window is open or not.

                   

                  In your example, you won't have a problem:

                   

                  windownames (get (filename)) will return "Window 1", "Window 2" or "Window 1 <P> Window 2" (<P> represents the carriage return)

                   

                  In this case,

                  PatternCount (windownames (get (filename)); "Window 1" ), returns a 1 only if "Window 1" is part of the string returned by Windownames and this is what you want.

                   

                  In my example, I had two windows: "Widgets" and "All Widgets"

                   

                  If the window "All widgets" is open and "Widgets" is closed.

                   

                  The pattern count function to test and see if the window "Widgets" is open would look like this:

                   

                  PatternCount("All Widgets","Widgets" )

                   

                  In this case, the function returns a 1 instead of 0 and the scripted test will fail.

                   

                  As long as you take care with your window names, you can avoid this problem.

                  • 6. Re: Is Window Closed ?
                    CountryBoy1
                      

                    Dear PhilModJunk:

                     

                                   I appreciate your explanation.  I had never used Pattern Count before and
                     will try to remember your tip in future applications.

                                   Sincerely,

                                            CountryBoy1