9 Replies Latest reply on Jun 19, 2014 12:00 PM by rouelf_1

    In FM Go cannot delete an external file with multiple tables using a script

    rouelf_1

      Title

      In FM Go cannot delete an external file with multiple tables using a script

      Post

           Using a MAC desktop, Have created a script, that obtains an empty found set, then use "Export Records". This works great for deleting an external FM file if the file has only one table. It works with FM Adv, it works with in runtime, and works in FM Go. However if the FM file has multiple tables, the script still works on the FM Adv to delete the desired file, but it does not work in FM Go.

           See my post in:  Remove / Delete a file on FileMaker Go 13. There I have posted the script that works for deleting an FM file that contains only one table.

           So, in FM Go, using a script, is there a way to delete an external FM file (in File On Device) that will delete a file with multiple tables ?

        • 1. Re: In FM Go cannot delete an external file with multiple tables using a script
          philmodjunk

               I can't imagine why the number of tables in the file would make any difference, except for this possibility: with multiple tables, there is a greater chance that the file is still open due to an external data source reference to one of those tables.

          • 2. Re: In FM Go cannot delete an external file with multiple tables using a script
            rouelf_1

                 Hello Phil

                 How I got this green check mark as the best answer beats me. The file running the script does not make any references to tables in the file to be deleted. Though the files do have identical table names, the file to be deleted is a copy of the file running the script, but of course the file has a different name.

            • 3. Re: In FM Go cannot delete an external file with multiple tables using a script
              rouelf_1

                   I have inserted error # trapping after the Export Records step to see what error # is occurring in FM Go. I get error #3, which is "Command is unavailable (for example, wrong operating system, wrong mode, etc.)"

                   OK, I can't make sense out of that message that helps fix this. The script works fine in FM Adv. But not in FM Go.

              • 4. Re: In FM Go cannot delete an external file with multiple tables using a script
                TSGal

                     rouelf:

                     Thank you for your post.

                     Are you attempting to export a FileMaker Pro file?  This will result in error 3.  Instead, export a tab-separated text file.  This will remove the file.

                     TSGal
                     FileMaker, Inc.

                • 5. Re: In FM Go cannot delete an external file with multiple tables using a script
                  rouelf_1

                       TSGal, thanks for your response. I am using to export a tab-separaterd text file, and results with error #3.

                  • 6. Re: In FM Go cannot delete an external file with multiple tables using a script
                    TSGal

                         rouelf:

                         I've just tried this out with a file that contains 30 tables.  No problem.  Here is the script I used:

                         Set Variable [ $FilePath ; Value: "file:" & Get (DocumentsPath) & "Test File.fmp12" ]
                         Show All Records
                         Show Omitted Only
                         Export Records [ No dialog ; "$FilePath" ; Macintosh ]      (only one field selected)
                         Set Variable [ $error ; Value: Get ( LastError ) ]
                         Show All Records
                         Set Field [ Table1::Name ; Table1::Name & " " & $error ]

                         -----

                         In essence, I exported zero records to a file, and I trapped for an error and put it into an existing field.  Naturally, "Test File.fmp12" is not open.

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

                         TSGal
                         FileMaker, Inc.

                    • 7. Re: In FM Go cannot delete an external file with multiple tables using a script
                      rouelf_1

                           TSGal, below is the script am using. I have tested it on a new file (with multiple tables) created in FM Adv 13, moved over to FM Go, and works perfectly. However, it does not work in my original file.

                           NOTE: My original file was created way back on FM Adv 7 or 8, and has been carried over to 9, 10, 11, 12, and 13. The file has about 20 tables, tons of layouts, and over 120 connected table occurrences. In short, it is a complex solution; perhaps some "corruption" has occurred in all the carrying over to newer FM software.  I suggest the concept of corruption, because not only deleting a file with a properly scripted script fails in FM Go; but also in FM Adv saving as a self-contained copy does not work. That is, saving as self-contained copy does not insert the actual files in containers (so have works-arround using scripts to change back and forth).

                           If the file is corrupted, is there a "reasonable" strategy for recreating with a new file using FM 13. I have tried procedures such as clone, compacting, Recovery (recovery shows no errors) and their various combinations to no avail. My only recurse to fix the malfunctions, I think, is to reproduce the solution using a new file. But reproducing the complex solution from scratch is daunting. Perhaps, FM has a "best strategy" for copying all scripts, layouts, relationships, customs lists, custom menus, security, and all, ... minus the malfunctions.

                            

                      #PURPOSE: deletes the _Update file.

                      #
                      Allow User Abort [ Off ]
                      Set Error Capture [ On ]

                      #

                      Set Variable [ $FilePath; Value:Get ( FilePath ) ]

                      Set Variable [ $FilePath; Value:Let ( [

                         Tag = "/";
                                             start = Position ( $FilePath; Tag ; 1 ; 1 ) ;
                                             end = Position ( $FilePath ; Tag ; start ; PatternCount ( $FilePath ; "/" ) )+1 ];
                                             If ( PatternCount ( $FilePath; Tag ) ;
                                             Middle ( $FilePath; start ; end - start ) ;
                                             "")
                                             )
                      ]

                      Set Variable [ $Path_Update; Value:"file:" & $FilePath & "YR_Update.fmpur" ]

                      #
                                          #This works only if you Export Records from a zero found set.

                      // Perform Script [ “DeviceAware” ]

                      Freeze Window

                      Go to Layout [ “People” (People) ]

                      Show All Records

                      Show Omitted Only

                      Export Records [ File Name: “$Path_Update”; Character Set: “Unicode (UTF-8)”; Field Order: People::File ] [ No dialog ]

                      # record the error

                      If [ Let ( [
                                             $last_err = Get( LastError )

                         ];
                                             $last_err

                         )]

                         # record the error

                         Set Variable [ $err_msg; Value:"Deletion Failed:¶ Could not Delete Records¶

                         due to error #" & $last_err ]

                         Show Custom Dialog [ Title: "Deletion Failed"; Message: $err_msg & "¶¶"& "In iOS, YR_Update¶

                         May Be Deleted Manually.¶¶
                                             To Delete: Go To File On Device,¶
                                             Swipe On YR_Update To The Left,¶
                                             and Delete.¶"; Default Button:
                      “OK”, Commit: “Yes” ]

                         Go to Layout [ original layout ]

                         Exit Script [ ]

                      End If

                      Show All Records

                      Go to Layout [ original layout ]

                      Show Custom Dialog [ Title: "Delete _Update File"; Message: "The File YR_Update.fmpur¶ Has Been Deleted From:¶
                                             The Same Location As:¶
                                             Family Data"; Default Button:
                      “OK”, Commit: “Yes”

                            

                      • 8. Re: In FM Go cannot delete an external file with multiple tables using a script
                        TSGal

                             rouelf:

                             Thanks for the additional information.

                             Since the script works properly in a new file, there is something in the original file that is not allowing it to work properly.

                             Recover is not a cure-all.  Just because Recover doesn't return any errors doesn't mean the file is damaged.  Recover will do its best to clean up a file so that it opens.

                             Before rebuilding the entire file, try creating a new table in the original file with some (or all) of the fields from the offending table/layout.  Duplicate your script and in the duplicate script, make references to the new table.  Move some of the records over from the original table to the new table, and then execute the duplicate script.  Does this work?

                             Since you mentioned that you are unable to save a copy of the file, the file may be damaged.

                             When I rebuild a file, I generally export each of the tables to text files using the Merge option, as this places the field names in the first record.  When I create a new file, I import the text files as it will create the field names in the new file.  Most of the time, I copy the objects from the layout of the old table to the clipboard and paste them into the new layout.  After each importing, try saving a copy of the file.  If it fails, then you can remove the layout objects and manually add them.

                             If you are able to make a clone of the file that is not confidential, feel free to send it in, and I'll see if I can locate why this issue is occurring.  If you cannot make a clone, then I'll look at your original file.  If you want to pursue either route, check your Inbox at the top of this page for instructions where to send a clone of the file.

                             TSGal
                             FileMaker, Inc.

                        • 9. Re: In FM Go cannot delete an external file with multiple tables using a script
                          rouelf_1

                               TSGal, just for clarification, I mentioned that in my solution saving as "self-contained copy" does not work. The file is saved, but the actual files are not inserted into containers as this file saving method is suppose to do.

                               I will try to setup my solution to "not use" custom menus, and set it up for external storage, to make it easier for you to use for checking the two malfunctions.