6 Replies Latest reply on Mar 25, 2015 4:47 PM by philmodjunk

    Script "Select Window" does not change current window

    PeterDow

      Title

      Script "Select Window" does not change current window

      Post

      I'm on Filemaker Pro Advanced version 13.0v5 connecting to a Filemaker database on Windows 2008 R2 Standard running Filemaker Server version 13.0v5 x64.

      The following script:

      Set Variable [$screenWidth; Value:Get(ScreenWidth)]
      Adjust Window [Resize to Fit]
      Move/Resize Window [CurrentWindow; Left: 25]
      Select Window [Name: "sbStudents"]
      Set Variable [$windowWidth; Value: Get(WindowWidth)]
      Show Custom Dialog ["Window width"; "Window width: " & $windowWidth]

      Does not work as I expect it to. There are two windows open when the script starts, "Sandbox" and "sbSTUDENTS", with "Sandbox" as the current window.  "Sandbox" is adjusted and moved to the left as expected.

      I expected the Select Window to make "sbStudents" the current window, and the Get(WindowWidth) to return the width of "sbStudents". Instead it returned the width of "Sandbox".

      What am I missing?

        • 1. Re: Script "Select Window" does not change current window
          SteveMartino

          Lets eliminate something obvious.  You Select Window to "sbStudents"   But you say "There are two..., "Sandbox"and "sbSTUDENTS",..  Is that a typo?

           

           

           

          • 2. Re: Script "Select Window" does not change current window
            SteveMartino

            Can't edit on iPad.  Did you try it with the script debugger to see if it's bringing the proper window to the foreground?

            • 3. Re: Script "Select Window" does not change current window
              PeterDow

              According to the documentation, Select Window is case-insensitive.  However, I did try it both ways, and (to answer your 2nd question), I used Show Dialog to display the result of Get(Window Name), which showed "Sandbox".

              Set Variable [$screenWidth; Value:Get(ScreenWidth)]
              Adjust Window [Resize to Fit]
              Move/Resize Window [CurrentWindow; Left: 25]
              Select Window [Name: "sbStudents"]
              Set Variable [$windowWidth; Value: Get(WindowWidth)]
              Set Variable [$windowName; Value: Get(WindowName)]
              Show Custom Dialog ["Window name: " &  "¶" & "Window width"; "Window width: " & $windowWidth]

              And the window width is also that of "Sandbox". "sbSTUDENTS" is about 4 times wider than "Sandbox".

              • 4. Re: Script "Select Window" does not change current window
                DavidJondreau

                A couple things...

                1) Try error trapping. Add the script step Set Error Capture [ On ] at the beginning of the script. After the Select Window[] script step, capture the result by adding Set Variable [ $error ; Get ( lastError ) ] and display $error in your custom dialog.

                2) Are both these windows showing layouts from the same file?

                • 5. Re: Script "Select Window" does not change current window
                  PeterDow

                  I added the Set Error Capture [on] and Set Variable($error...) and it displayed nothing in the Show Custom Dialog.

                  And no, each window is showing a layout from a different file.  Since they both showed up in the WindowNames results, I assumed I could simply select either one with the Select Window. I unchecked the "Current file only".  I didn't see a way to specify a file other than "current file".

                  Oops! My mistake. My Show Custom Dialog had an extra period after $error, so it showed nothing. After removing that, it shows 112 "Window is missing".

                  After some research, I tried adding Open File [Open hidden; "sbSTUDENTS"] right before the Select Window["sbSTUDENTS"] but it didn't help. Well, it no longer gets the 112 error.  But it still doesn't switch windows.

                  • 6. Re: Script "Select Window" does not change current window
                    philmodjunk

                    "Window is missing" would indicate that you haven't quite named the window accurately in your select window step and that would explain why you are getting stats from the other window. It can be something very simple and hard to spot in how you specify the window names.