5 Replies Latest reply on Feb 24, 2010 1:03 PM by liquidcooled

    Create Script to detect ODBC File

    liquidcooled

      Title

      Create Script to detect ODBC File

      Post

      Hello, 

      I'm new to filemaker and have a database that "syncs" with an external ODBC database. I have a script "syncs / imports" data from the ODBC source. My script works great except for when my ODBC database is not available I get an error message from filemaker that says " "?" could not be opened. (Not Found) " How can I write a script that will Detect this error create a custom message for the user that is more informative and also exits the script so that it does not continue to try and import the other files. 

       

      I think that I need to use Get (LastODBCError) but I'm not sure how to use that with the error message supplied by FM.

      Thanks 

        • 1. Re: Create Script to detect ODBC File
          SCOPe
             Have you walked through your script when the DB is not accessable to see the FileMaker error returned in the script? If so, what is the error supplied?
          • 2. Re: Create Script to detect ODBC File
            SCOPe
              

            Also based on the ODBC message you are getting, you could do something like the following in your script:

             

            Set Variable[$ODBCError; Value:Get ( LastODBCError)] If [$ODBCError = "'?' could not be opened. (Not Found)"] Show Custom Dialog [] Exit Script [] End If

             


             

            Once you walk through your script with the debugger you should be able to pinpoint where this error is happening in the script, and put this right after that step.

            • 3. Re: Create Script to detect ODBC File
              mrvodka
                 I believe that you should be able to trap for this using a standard error trap. It should error out on the Import. You can use Get ( LastError ) after you turn error capture on.
              • 4. Re: Create Script to detect ODBC File
                SCOPe
                  

                mr_vodka wrote:
                I believe that you should be able to trap for this using a standard error trap. It should error out on the Import. You can use Get ( LastError ) after you turn error capture on.

                That would probably work as well, just need to find what standard error # it's throwing, and catch it. Probably a lot more efficent then the Get (LastODBCError), inless your trying to figure out what that specific error string is, which you will not get from the standard filemaker Get (LastError). Just depends on what your looking to do with it.

                 

                If your looking to supply debugging information in that custom message, I would go with Get (LastODBCError)

                If your just looking to catch this error and exit the script, Get (LastError) would be a much safer route.

                 

                These links might be of some help:

                Get (LastError)

                Get (LastODBCError)

                List of FileMaker Error Codes


                • 5. Re: Create Script to detect ODBC File
                  liquidcooled
                     As I said I'm new to filemaker and I didn't notice in the debugger the handy little Last Error: section. It was using error code 802. I used the script from SCOPe but with Get (LastError) instead of the Get (LastODBCError) and used the Error code 802 in my IF. Thanks a lot for all the help!