1 2 Previous Next 24 Replies Latest reply on May 9, 2014 11:56 AM by Maclurv

    Doomed to not understand filepaths?

    Maclurv

      I'm feeling dense at the moment. Have been looking at Help and references about save records as pdf to a file located on the user's desktop. The solution is used locally on a user's computer. Scripted based on my understanding, and all I get is the 800 error message. What is it that I am not getting? I would like the script to work with Mac or Windows. Here is what I scripted:

       

      Else If [Get LastMessageChoice = 2]

      Set Variable [$file; Value: "Product Price List"]

      Set Variable [$path; Value: Get (DesktopPath) & $file]

      Save Records as PDF [Restore; No dialog; "$path"; Records being browsed]

       

      It is after the last step where the 800 error occurs. I am using a Mac with Maverick OS.

       

      Thanks for any assistance.

       

      Pat

        • 1. Re: Doomed to not understand filepaths?
          Mike Duncan

          Hi Pat,

           

          Try

          $path =

          "file:" & Get ( DesktopPath ) & $file & ".pdf"

          • 2. Re: Doomed to not understand filepaths?
            Stephen Huston

            I have a custom function "SavePDF" which handles both Mac and Windows file systems for saving to the desktop:

            • Choose ( Abs ( Get ( SystemPlatform ) ) -1 ; Get ( DesktopPath ) & NameToUse & ".pdf"; "filewin:"& Get ( DesktopPath ) & NameToUse & ".pdf" )
            • the function requires one parameter — "NameToUse" — which you can set to a variable such as $filename.

            So your script would set a $filename and a $path, with the $filename equal to the actual name of the file to be saved (without the extension, the CF takes care of that for you), and the $path would be the function: SavePDF($filename)

            • 3. Re: Doomed to not understand filepaths?
              Maclurv

              Thanks, Stephen, I will try and add your custom function and try that, however, I have tried the 'Get (DesktopPath) & NameToUse & ".pdf" part before (both with a "file:" preceeding and without) and it doesn't seem to work, which is essentially also what Mike just suggested and it didn't work. This is what is driving me bonkers! I replicate what I see (at least, I think I do!) in Help and other sources, and it doesn't work. 

               

               

              Will let you know if your custom function idea works!.

               

              Pat

              • 4. Re: Doomed to not understand filepaths?
                Maclurv

                Nope, didn't work either. Here is the custom function as I understood it:

                 

                 

                SavePDF custom function with NameToUse as parameter:

                 

                 

                Choose (

                 

                 

                Abs ( Get ( SystemPlatform ) ) ; -1 ; Get ( DesktopPath ) & NameToUse & ".pdf" ;

                 

                 

                "filewin:" & Get ( DesktopPath ) & NameToUse & ".pdf" )

                 

                 

                Here is the scripting that went with it:

                 

                 

                Else If [Get LastMessageChoice = 2]

                   Set Variable [$file; Value: "Product Price List"]

                    Set Variable [$path; Value: SavePDF ($File)]

                   Save Records as PDF [Restore; No dialog; "$path"; Records being browsed]

                 

                Thanks.

                • 5. Re: Doomed to not understand filepaths?
                  BarbaraCooney

                  you’re missing the filename extension.

                  • 6. Re: Doomed to not understand filepaths?
                    Stephen Huston

                    I have a demo file originally built in FM11, but converted to FMP12 still works fine in my tests. It has a slightly different CF built into it, and was originally set to allow saving various formats from FMPro (but not Go). Try running the script and choose the options Print /and/ PDF to see if it will save a file to your desktop. If it fails, there may be a problem with your permissions, in which case a visit to Repair Permissions via the Disk Utility is in order.

                     

                    Let us know how it goes.

                     

                    The attached ziped file opens with the admin/Full Access account by default, so it's ready to unzip and use.

                    • 7. Re: Doomed to not understand filepaths?
                      Stephen Huston

                      The Custom Function provides the extension in this case.

                      • 8. Re: Doomed to not understand filepaths?
                        erolst

                        The path from your sample works on my FM13 & Mavericks, without "file:/" and ".pdf".

                         

                        Since you're using a constant as filename, the problem may be an attempt to overwrite an existing and opened file (which is a problem with e.g. Excel, though, strangely enough, not with Preview …)

                         

                        Maybe add a unique identifier to the name, like a timestamp with substited path delimiter characters (":" and "/").

                        • 9. Re: Doomed to not understand filepaths?
                          Maclurv

                          Hmm... Just had a crash last week which sent me to the Genius Bar and reclaiming via Time Machine and reformatting my hard drive. Let me try disk permissions first, then I'll retry what I've done, and if not successful, will poke my head into your generous download.

                           

                          Thanks!

                          • 10. Re: Doomed to not understand filepaths?
                            Stephen Huston

                            (a note in passing: the demo file I uploaded adds a timestamp to the file name via a custom function, so there is no overwriting of existing files with my example file.)

                            • 11. Re: Doomed to not understand filepaths?
                              Maclurv

                              Kill me now. It still isn't working!

                               

                              First, I repaired disk permissions and tried again. No go.

                               

                              Next, I imported the custom function and ran again. No go.

                               

                                   Set Variable [$file; Value: "Product Price List" & Get (Current Time)]

                                   Set Variable [$path; Value" SaveAs ($file; ".pdf")]

                                   Save Records as PDF [Restore; No dialog; "$path"; Records being browsed]

                               

                              Last, I added a time stamp to the file name. No go.

                               

                              I'm using FM Advanced 13 and Mavericks, so what's up?

                               

                              Thanks for the help.

                              • 12. Re: Doomed to not understand filepaths?
                                Stephen Huston

                                Try the demo file I posted earlier this afternoon, and see if you can use the script's Print / PDF options to successfully save a file to your desktop. That file was verified to be working earlier today on my development system.

                                • If it does not work on your system then the issue is in your local system.
                                • If it does work, then there's something not quite right in the functions or script you are building in your file.
                                • 13. Re: Doomed to not understand filepaths?
                                  beverly

                                  The "paths" are different per platform, as well. Perhaps in my reply to this thread you will see what I use:

                                   

                                  <https://fmdev.filemaker.com/message/143010#143010>

                                   

                                  I had the need to come up with something that might work on Mac, Windows, iPad, Server. I use $variables so I can debug.

                                   

                                  You should research these functions:

                                       Get ( SystemPlatform )

                                       Get ( DesktopPath )

                                       Get ( DocumentsPath )

                                       Get ( TemporaryPath )

                                       Get ( FileMakerPath )

                                   

                                  In the help are links to examples of setting the filepath by variable.

                                  HTH,

                                   

                                  Beverly

                                  • 14. Re: Doomed to not understand filepaths?
                                    PeterWindle

                                    side note: it might also be worth mentioning that if the file is actually open whilst you're script is trying to save a file in the same location, with the same name... you will also get an error.

                                    1 2 Previous Next