4 Replies Latest reply on Sep 29, 2009 5:40 PM by RayMentor

    The Great FilePath Mystery

    RayMentor

      Title

      The Great FilePath Mystery

      Post

      File paths are my nemesis. I continue to get tripped up on terms like "absolute, relative, local, etc.". I've reviewed the FM help file record(s) about file paths, but apparently I need a simpler explanation. The geekspeak in the help note hasn't dispelled the darkness yet.

       

      Here's why I need to wrap my brain about this.

       

      I frequently need to create scripts that all a networked user to save his or her found records as Excel or PDF, attach to an email and send.  

       

      Usually I'm working from a hosted FM 10 file in Filemaker Server 10 in a network situation which is either all Mac, all Windows, or mixed Mac and Windors.

       

      Of course, there's strategy of the "Save Records as Excel / PDF" script step and then click the option to create an email. However, I typically want to supply the email address because it's available in the database. Most often, I do something like:

       

      Set Variable [$FilePath; Value: "file:" & Get (TemporaryPath) & "Proceeds.xls"

      Export Records [No dialog; "Proceeds.xls"

      Send Mail [Send via E-mail Client; Subject: "Proceeds report & Get (CurrentDate); $FilePath

       

      Sometimes it works and sometimes not.

       

      Can anyone do any of the following:

       

      1) Direct me to an explanation of paths written for someone who is not a computer science major

      2) Share a reliable script that will send the attachment no matter what the system user is on

      3) Point out the error of my ways in the short script example I cited above

       

      Much obliged for any assistance. Thanks in advance. 

       

        • 1. Re: The Great FilePath Mystery
          RayMentor
             Still looking for a hand with this. Appreciate any ideas or leads.
          • 2. Re: The Great FilePath Mystery
            FentonJones
              

            Yes, you're right that the "absolute" and "relative" paths are the cause of your problem. "Relative" means "relative to the open local FileMaker file." In a networked situation there is no local file. Also, the FileMaker functions, like Get (TemporaryPath), return paths meant to be used in absolute paths; they begin with a / (root). They are not however complete, because they don't have the OS system prefix (why, I don't know, maybe so they can be used otherwise?).

             

            So you should use an absolute path; which requires a prefix for which platform you're on. That is NOT provided by Get (TemporaryPath), so you need to add it. There is a function to do so, but you need to know how to use it. Example, using Let() to set up the correct prefix and filepath for a variable:

             

            Let (

            prefix = Case ( Abs ( Get (SystemPlatform)) = 1; "filemac:"; "filewin:" );

             

            prefix & Get (TemporaryPath) & "Proceeds.xls"

             

            (hope that's right, FileMaker is busy right now, so above is pseudo code) 

            • 3. Re: The Great FilePath Mystery
              RayMentor
                 Thanks, Fenton. I'll reread your post in the morning when I have more brain cells firing. Appreciate your sharing your insights.
              • 4. Re: The Great FilePath Mystery
                RayMentor
                   Got in late tonight so I'll take advantage of your response tomorrow and test it out. Thanks again.