2 Replies Latest reply on Dec 19, 2013 7:50 AM by macmesser

    Exiting a script with conditional execution

    macmesser

      Title

      Exiting a script with conditional execution

      Post

           I have a script with a custom dialog with three buttons, which I want to perform one of two searches based on button returned or do nothing and simply exit the script, which appears below. Is the exit script[ ] step needed or even correct? The help file says exit script [] is used to exit an external script or subscript. Will it work in this way or should I just leave the final "else if" clause empty? What would be the best way to pass a value from this script if the final "else if" clause is executed? Thanks for any insights. ps- how do I change text size on this forum?

           Show Custom Dialog [ Title: "Display records according to keywords"; Message: "Do you wish to show records with or without a value
           for the keywords field (Custom Field 1)?"; Default Button: “Show with keywords”, Commit: “No”; Button 2: “Show without
           keywords”, Commit: “No”; Button 3: “Cancel”, Commit: “No” ]
           If [ Get ( LastMessageChoice )=1 ]
           Perform Find [ Specified Find Requests: Omit Records; Criteria: Inventory_Items_POS::Custom Field 1: “=” ]
           [ Restore ]
           Else If [ Get ( LastMessageChoice ) = 2 ]
           Perform Find [ Specified Find Requests: Find Records; Criteria: Inventory_Items_POS::Custom Field 1: “=” ]
           [ Restore ]
           Else If [ Get ( LastMessageChoice ) = 3 ]
           Exit Script [ ]
           End If

            

        • 1. Re: Exiting a script with conditional execution
          philmodjunk

               When a script performs the last step in your script, it will exit whether or not you include Exit Script. So you don't need it in the script you have posted here.

               Exit Script has several key uses.

               Sometimes you want a script to exit inside an If block in the middle of your script.

               Sometimes your script is a subscript--it's called by a Perform Script step in another script, and you need to return a value to the other script.

               Some Script Trigger performed scripts need Exit Script [False] in order to "cancel out" the event that triggered the script. (This only works with triggers that are tripped and perform a script before the triggering event is processed. See "Setting up Script Triggers" in FileMaker help to see a table of all triggers that shows which can use this script step to do that.)

          • 2. Re: Exiting a script with conditional execution
            macmesser

                 Thanks Phil. So not needed where I put it but would be useful to get out of the script inside if block and in a few other  cases.