5 Replies Latest reply on Jul 14, 2014 10:18 AM by philmodjunk

    Get(LastError) not working properly

    WarrenHavens

      Summary

      Get(LastError) not working properly

      Product

      FileMaker Pro

      Version

      10.0v3

      Operating system version

      10.9.4

      Description of the issue

      I am using the following script:

      Set Error Capture [Off]
      Perform Find [Restore]
      Set Variable [$LastError; Value;Get(LastError)]
      Show Custom Dialog [$LastError]

      I have made sure that the "Perform Find" step should return an error.  When I run the script while on some layouts I get a Filemaker error, click "continue", then the Show Custom Dialog box shows "401".  This is obviously the expected result.

      When I run the script while on other layouts I get a Filemaker error, click "continue", then the Show Custom Dialog box shows "0".  On still another layout, I got no error and a "0" which would be a fine result except that it shouldn't have found anything.

      It is like my FMPro is wigging out!  I can't see that I am doing anything wrong, yet I am not getting the expected results.

      Any help would be appreciated.

      Steps to reproduce the problem

      Listed above.

      Expected result

      "401"

      Actual result

      "0"

        • 1. Re: Get(LastError) not working properly
          WarrenHavens

               I played around with it a little more using a new, blank layout and it works.  This makes me think that there may be a script trigger on the layout that is getting run between the Perform Find command and the Set Variable command.  That still feels like a bug to me.

          • 2. Re: Get(LastError) not working properly
            philmodjunk

                 One way to see if a trigger performed script is interrupting a given script is to use FileMaker Adavanced's debugger to run the script one step at a time. If a trigger for a script is tripped, you'll see that script pause the current script and then your debugger starts stepping through the trigger controlled script.

                 OnRecordLoad
                 OnModeEnter
                 OnModeExit

                 are all triggers that the above script might trip before or after the find is performed.

            • 3. Re: Get(LastError) not working properly
              philmodjunk

                   But I do agree that this appears to be a bug.

                   I set up a script: Show Custom Dialog [Get ( ScriptParameter ) ]

                   And then setup the above triggers on a layout with different parameter expressions for each trigger.

                   I then ran the same script shown here with criteria specified that I knew would fail to find any records.

                   I saw multiple dialogs pop up due to the script triggers being repeatedly tripped by this script, but no error code is shown in the final custom dialog.

                   If I then remove the triggers from Layout setup, I get an Error code of 401 in the custom dialog as expected.

              • 4. Re: Get(LastError) not working properly
                Fred(CH)

                     Hello,

                     Wow : interesting case wink.

                     If the Perform Find step is performed on a layout where the triggers indicated by Phil are installed, you may would to capture the error within a Set Variable [$$error] step, as the first command of an OnModeExit triggered script, with the Search Mode activated on the trigger.

                     Because you are able to capture the 401 error since exiting the search mode.

                     However, i do not think the Set Error Capture [Off] when starting the main script is truly relevant here.

                     Bye, Fred

                • 5. Re: Get(LastError) not working properly
                  philmodjunk
                       

                            i do not think the Set Error Capture [Off] when starting the main script is truly relevant here.

                       It keeps the script from halting on a FIleMaker spawned error message when no records are found. wink

                       The main concern is that an error code generated in a script should not be wiped out by a different script that interrupts the first script. Just as a local variable, $Variable, should store data specific to the script in which it was created, so Get ( LastError ) should function from the data scope of the script where it was placed instead of behaving as though the trigger performed scripts were magically inserted into the middle of the script that tripped their triggers.