1 Reply Latest reply on Feb 7, 2013 11:36 AM by TSGal

    File Exists check

    screamingmonkey

      Title

      File Exists check

      Post

           So I have a database that I use to create a seperate database named differently from.  I have everything working on the PC where if the database exists it will open, if it does not it will create it.  When I take it to FMP Go it does not work anymore.  The error code I get on the PC when it can't find it is 100 on the iPad it's giving me 4.  Now the other problem is if the database does exists it still gives an error 4 that it can't find it and over writes the original database.

           I am using the following to see if the file exists.  File is setup with 2 fields combined to create a custom code for our needs.  Then it will open that file and close the current master file.  I am having to use the Open URL to open the file as the current open file can not take variables, which is really annoying.

           Import Records [No dialog; "$file"; Update existsing; Windows ANSI]
           If [Get(LastError) = 100]
             Save a Copy as ["$file"; Automatically open; copy]
           Else If [Get(LastError) = 100]
             Open URL [No dialog; "file://" & $file]
           End If
           Set Error Capture [Off]
           Close File [Current File]

            

            

           So any ideas on how to get it to check for a file before it creates one would be nice, as I can not deploy this out with the dangers of having it create a new file over top of one that has data in it already and thus delete the previous file.

        • 1. Re: File Exists check
          TSGal

               Kevin Struckman:

               Thank you for your post.

               First, an error 4 is "Command Unknown".  In Manage Scripts, select your script, and at the bottom, change the pop-up below Show Compatibility to "iOS".  This will then show you what commands are allowed in FileMaker Go.

               What is the contents of the $file variable?

               When using "Open URL", you need to use "fmp://" for FileMaker Go 12, and "fp7://" for FileMaker Go 11.

               For testing purposes, insert after each script step "Show Custom Dialog" step using "Get (LastError)" function to return the last error from each step.  This will allow you to step through the script steps and narrow down the issues.

               TSGal
               FileMaker, Inc.