4 Replies Latest reply on Mar 1, 2012 7:20 PM by PaulWebb

    Script stuck in Pause...missing something



      Script stuck in Pause...missing something


      Hi All...

      When my file opens a script called Startup runs which does the following.

      • Allow User Abort [ Off ]
      • Set Error Capture [ On ]
      • #---------------------------------- Opens the home page on startup.
      • Show/Hide Status Area [ Hide ]
      • Adjust Window [ Resize to Fit ]
      • Move/Resize Window [ Current Window; Top: (Get ( WindowDesktopHeight ) / 4) - (Get ( WindowContentHeight )/4); Left: (Get ( WindowDesktopWidth ) / 2) - (Get ( WindowContentWidth ) / 2) ]
      • #---------------------------------- Create Alerts popup
      • Perform Script [ “Alerts” ]
      And the Alerts script does...
      • Allow User Abort [ Off ]
      • Set Error Capture [ On ]
      • Show/Hide Status Area [ Hide ]
      • #---------------------------------- Opens a new window for Alerts.
      • New Window [ Name: "Alerts"; Top: ( Get ( WindowDesktopHeight ) / 4 ) - ( Get ( WindowContentHeight ) / 4 ) + 10; Left: ( Get ( WindowDesktopWidth ) / 4 ) - ( Get ( WindowContentWidth ) / 4 ) ]
      • Allow Toolbars [ Off ]
      • Go to Layout [ “Alerts” (SR) ]
      • Adjust Window [ Resize to Fit ]
      • #---------------------------------- Pausing the script locks the user out of everything else until they close the window.
      • Pause/Resume Script [ Indefinitely ]
      • #---------------------------------- Closes the window when the button is clicked.
      • Close Window [ Name: "Alerts"; Current file ]
      Everything seems to work as planned. After I hit the close button to close the popup my script is still paused. I've tried several things with no luck. Curious what I am missing.
      FM Pro 11 Advanced
      PS - Also trying to line up the popup window in the middle of the main window. So if someone can help with the New Window step I'd appreciate it.

        • 1. Re: Script stuck in Pause...missing something

          Include a halt script step for every method you are enabling for closeing the window. Buttons can specify this in button setup in the current script drop down. Scripts can make this the last step in the script. You can use a custom menu to update the close window menu option to run a script that both closes the window and then usess halt script to halt the paused script. (And I'd put the pause inside an infinite loop so the user can't continue the script by just pressing the enter key.)

          Centering one window on another is a matter of correctly computing the top and bottom values for the New Window command based on the position and size of both windows.

          Get functions can be used capture the size and position of the first window and put the values in variables before you open the new window.

          $LeftOldWindow + $WidthOldWindow/2 - $WidthNewwindow/2

          Would calculate the left edge of your new window to horizontally center it, to give one example.

          • 2. Re: Script stuck in Pause...missing something

            I originally had my close button on my popup set to Close Window. I changed it to Resume Script and that did the trick. Only potential problem I see is if somehow the script were to be exited prior the close button would then have no effect. But I don't really see how one coould exit the script. I had tried a Halt Script step at the end of each script but see that once you hit the close button there would be no way to continue the script. I think the Resume Script on the button is a pretty good option. Let me know if you have something more efficient/foolproof.


            Thanks for the tip on the window. I'll play around with it.

            • 3. Re: Script stuck in Pause...missing something

              Given how you've written that script, resume should work. There is one caveat. Is it a problem for you if the user presses the enter key? That will also resume your paused script and close the window.

              If that is an acceptable result, no problem. If you don't want an enter key press to close the window then the alternative is to enclose the Pause step in side an infinite loop and then you must use Halt Script to terminate the infinite loop.

              Recently, I've had to adapt a solution to work with dual monitors with a different window open in each monitor. Since show custom dialog does not provide me with a way to control where it will open, I've had to replace all the show custom dialog steps with my own sub script that uses new window to open my own version of a message dialog in the appropriate location.

              I came up with this loop:

              Set Variable [$$Button ; value: "" ]
                 Exit Loop if [Not IsEmpty ( $$Button ) ]
              End Loop

              The buttons are really fields with a drop shadow effect so my script can put text from a script parameter into the fields to label them. The fields are then set up as buttons with a parameter expression that passes the value of the field to a script that does this:

              Set Variable [$$Button ; Get ( ScriptParameter ) ]

              and these buttons have the resume option specified.

              This way, I can exit the loop and then test the value of $$Button to determine which button was pressed.

              But I also have a close window script that simply closes the window and terminates with Halt script that I use with a custom menu so that clicking the close control in the upper corner of the window still halts the script--and provides the functional equivalent of clicking Cancel. (It also determines whether or not to maximize windows after closing...)

              • 4. Re: Script stuck in Pause...missing something

                I don't think hitting enter should be a problem. Might make things easier on the user.


                Thanks for the tip on the loop/multi monitor. I'll keep that in my back pocket.