6 Replies Latest reply on Oct 4, 2016 10:30 AM by justinc

    Get(ScriptResult) returns old result if recent script returns nothing

    travispressestheredbutton

      Summary

      Get(ScriptResult) returns old result if recent script returns nothing

      Product

      FileMaker Pro

      Version

      13

      Operating system version

      Mac

      Description of the issue

      Get(ScriptResult) description is "Use this function as part of a calculation evaluated within a script. If a subscript doesn’t return a result, then the content of the script result will be empty."

      But if a script exists with no value then Get(ScriptResult) is returning the value of the next previously run script.

      Steps to reproduce the problem

      I created four scripts. The first three just contained the script "Exit Script". One exited with an empty value. The next returned "Hello Test". Finally the third returned "Goodbye Test". The last script ran them and tested the returned value from Get(ScriptResult) in order: No Result; Hello Test; No Result; Goodbye Test; No Result

      Expected result

      No Result: Empty;
      Hello Test: "Hello Test";
      No Result: Empty;
      Goodbye Test: "Goodbye Test";
      No Result: Empty;

      Actual result

      Calling script with no result
      Success - script returned ""
      ======================
      Calling script expecting "Hello Test"
      Success - script returned "Hello Test"
      ======================
      Calling script with no result
      Failure - script returned "Hello Test"
      ======================
      Calling script expecting "Goodbye Test"
      Success - script returned "Goodbye Test"
      ======================
      Calling script with no result
      Failure - script returned "Goodbye Test"

      Workaround

      I have to call Exit Script with "" to ensure it returns nothing.

        • 1. Re: Get(ScriptResult) returns old result if recent script returns nothing
          TSGal

          Travis Spangle:

          Thank you for your post.

          I am unable to replicate the issue.

          If the fourth script is calling the first three, you should only have three results.  Can you clarify why you have five results?

          Here are my four scripts:

          Script1:
             Exit Result [ ]

          Script2:
             Exit Result [ "Hello Test" ]

          Script3:
             Exit Result [ "Goodbye Test" ]

          Script4:
             Perform Script [ "Script1" ]
             Show Custom Dialog [ Get (ScriptResult) ; Get (ScriptResult) ]
             Perform Script [ "Script2" ]
             Show Custom Dialog [ Get (ScriptResult) ; Get (ScriptResult) ]
             Perform Script [ "Script3" ]
             Show Custom Dialog [ Get (ScriptResult) ; Get (ScriptResult) ]

          -----

          I execute Script4, and I get the results <blank>, "Hello Test" and "Goodbye Test".

          Let me know what I'm doing differently than you so I can replicate the issue.

          TSGal
          FileMaker, Inc.

          • 2. Re: Get(ScriptResult) returns old result if recent script returns nothing
            travispressestheredbutton

            Thanks for testing TSGal,

            In your scripts, try calling Script1 after 2 and again after 3. I would expect Get(ScriptResult) to be <blank> every time Script1 is called because it didn't return anything. According to the documentation on http://www.filemaker.com/help/12/fmp/html/func_ref2.32.71.html

            "If a subscript doesn’t return a result, then the content of the script result will be empty."

             

            That's why you're seeing 5 results. 

            • 3. Re: Get(ScriptResult) returns old result if recent script returns nothing
              TSGal

              Travis Spangle:

              Thanks for the additional instructions.  I can now replicate the issue.

              I discovered Development and Testing are aware of the issue, and a resolution was setting the return result in the Exit Script command to clear the previously set value.  I realize this is not what appears in the documentation.  Let me research this further to gather more information.  I'll update you when I know more.

              TSGal
              FileMaker, Inc.

              • 4. Re: Get(ScriptResult) returns old result if recent script returns nothing
                Fred(CH)

                Mmhh, i alway thought this behavior was "as designed"...

                It is like a global variable that you set or not. And if you execute Set Variable step without specifying any result, you will get the same behavior : no change of existing value.

                I bet it will be a documentation fix...

                • 5. Re: Get(ScriptResult) returns old result if recent script returns nothing
                  TSGal

                  travispressestheredbutton:

                   

                  This issue is now documented in FileMaker Pro 15 Help.  From Help, go to:

                   

                  Reference -> Functions Reference -> Get Functions -> Get ( ScriptRestult )

                   

                  Under Description, it says:

                   

                  "Use this function as part of a calculation evaluated within a script. If a sub-script doesn’t return a result, then the contents of the script result will either be empty or the value of any previous sub-script result. To control the value of a sub-script result, use the Exit Script script step in the sub-script and specify a result."

                   

                  TSGal

                  FileMaker, Inc.

                  • 6. Re: Get(ScriptResult) returns old result if recent script returns nothing
                    justinc

                    I just ran across this issue today (FMPA 15.02).  I don't consider updated documentation a 'fix' - I think this behavior is the wrong design.  It should do what it says on the tin.  "Didn't you read the owner's manual?  Putting the automatic transmission indicator at 'R' causes the car to go forward."

                     

                    I realize that there other paradigms on how to think about how this works...but why should we have to come up with mental gymnastics to explain it?  Why would 'get(scriptresult)' EVER show you a result that is different than the last script run?  Just like proper garbage collection of your own global variables, things should be reset when you use them again.

                     

                    A null value is a valid result, in my estimation.  FileMaker treats null as TRUE, if you use it as result for a trigger script that happens before the event.  That is, a trigger on a pre-execution event will only cancel that event if the script result is explicitly 0 or FALSE.  Would the triggers also get caught up in this behavior for 'get(scriptresult)'?  I.e. if I call a script that returns 'FALSE' (not related to a trigger) and then a trigger fires that has a NULL result, would it actually register the FALSE result from the previous script run, and perhaps cancel the trigger event?