7 Replies Latest reply on Nov 11, 2016 4:02 AM by alext

    Script parameter on pause

    Hudi

      is there a way to get around the absence of script parameter on the 'Resume Script' command?

      I don't want to write two short scripts. If the user chooses to abort, the script should recognize that and react accordigly.

       

      This is not a huge deal but just something that has been bugging me lately.

       

      thanks

       

       

      Screen shot 2013-03-08 at 10.51.01 AM.png

        • 1. Re: Script parameter on pause
          ErikWegweiser

          Hi. I'm not certain what you're asking or what this script does (absent any other routines or layouts involved, of course).

          For instance, the Get(ScriptParameter) after the pause is confusing to me so far.

          Also, I'm assuming Allow User Abort is off.

           

          Here's a couple things that may be useful.

           

          A Get(ScriptResult) step immediately following the Pause step in a script will capture the results of whatever OTHER script step was run while THIS script was paused. So the pause may occur on a layout contianing a [resume] buttton that runs a script. That script might have "cancel" as the Exit result, upon which the currently paused script can act.

           

          I often use buttons on dialog layouts that run a script, passing a parameter, such as "cancel." That script is a simple utility with only one step: Exit Script [Result = get(Scriptparameter)].

           

          Because, as you noted, there is no parameter passed if the user simply resumes the script, null must be considered as well.

          It can be tricky to think through all the possibilities of what can happen while a script is paused and make sure you capture results when necessary, but I hope this helps.

          1 of 1 people found this helpful
          • 2. Re: Script parameter on pause
            DavidJondreau

            A cancelled script is, well, cancelled, so script parameter or no, the rest of the script won't run.

             

            You have a couple options. You can use two scripts (why not?). Or you can  Set User Abort [Off] so users cannot cancel. Then create a new button for cancelling on your layout that creates a global variable and set it to Resume scripts. Have your parent script check for that variable.

            • 3. Re: Script parameter on pause
              fitch

              "I don't want to write two short scripts. If the user chooses to abort, the script should recognize that and react accordigly."

               

              If you're saying the Resume Script step should offer a script parameter option, I agree that would be a handy feature.

               

              Given that it doesn't, my preference would be to go with two scripts. I've been thinking a lot lately about managing complexity in FileMaker development, and I think there is a tendency to cram too much into one script. Break it out into logical modules, make good use of Get(ScriptParameter) and Get(ScriptResult), and your future self (or other developers) will thank you.

              1 of 1 people found this helpful
              • 4. Re: Script parameter on pause
                Hudi

                Erik,

                 

                Thanks for your help.

                I often use buttons on dialog layouts that run a script, passing a parameter, such as "cancel." That script is a simple utility with only one step: Exit Script [Result = get(Scriptparameter)].

                How does this resume the originally paused script. If I understand correctly, please correct me if not, you run a script that pauses on a layout which has a button with a one-step-script attached to it. That script contains one command which is Exit Script [Result = get(Scriptparameter)]. I tried this and the originally paused script does not respond, it remains paused as there is no Resume Script step to tell it to. Am I doing something wrong?

                 

                Cheers

                • 5. Re: Script parameter on pause
                  Hudi

                  Why not. Indeed.

                  Two scripts it is.

                  • 6. Re: Script parameter on pause
                    ErikWegweiser

                    This button is not simply 'resume' but runs a script, passing the script a parameter, such as "cancel" — However, on the layout, the button would be set to 'resume' the currently running script, rather than the default, which is 'pause.'

                     

                    So I have a script, called 'Resume with Parameter as Result' with that one script step, "Exit [get(scriptparameter)]"

                     

                    On the 'modal dialog' layout, I have two buttons (at least). One is a normal Resume only button (no script). The other is the 'Cancel' button that runs the 'Resume with parameter..." script, resuming the paused script.

                     

                    My 'modal dialog' script usually looks something like this:

                     

                    Allow user abort [off]

                    Open new window

                    go to dialog layout

                    Install my limited custom menu set ("Dialog")

                    hide status area [lock]

                    Loop

                         Perform Script: Resume with Parameter as Result [no parameter] {note1}

                         Pause

                         set $result = get(scriptresult)

                         exit loop if $result = "cancel"

                         ...

                         business logic, validation, etc. etc.

                         set $error = boolean 0 means validation OK; boolean 1 means can't let the user continue yet

                         ...

                    exit loop if $error = 0

                    End Loop

                    Close window

                    ...

                    If $result = "cancel"

                         business logic if user canceled

                    else

                         business logic if user did not cancel

                    End If

                     

                    {Note1: This is here to 'reset' whatever the script result is of any script or button that runs while this script is paused}

                     

                    At no point is there the ability for the user to Halt scripts altogether, close the window or abort the running script, other than via the Cancel button within this script control.

                    • 7. Re: Script parameter on pause
                      alext

                      I recently was thinking about this b/c I wanted to set up a cancel for users on a pause script & spent some time thinking about the most efficient approach.  "Resume Script" with a parameter would be the ideal but of course doesn't exist, so the next cleanest way I found was to do all the work in Script A (my preference), call Script B to pause only, then use Exit Script command with a parameter for any button on the layout to pass data back to Script A.