6 Replies Latest reply on Nov 8, 2016 4:59 PM by thurmes

    Script - Specify Output File Path questions


      I edited this because I realized that I had an extra / in my file path.




      I get my script to run just fine and have the exported Excel file go into the same folder as the FMP File, but what I want it to do is go to a relative path above the containing folder. I can't use a fixed file path because each client has their own FMP database, which is filed about 50 different ways.


      currently I have: File:/Site Survey/Lables.xlsx


      Screen Shot 2016-11-08 at 3.58.35 PM.png


      First, I have been getting this error. I tried changing the name and deleting the existing file, but that doesn't help.


      Screen Shot 2016-11-08 at 3.57.22 PM.png


      Ideally I would like the script to work up the folders----> meaning it would save in "Site Survey"in a perfect world, it would go backwards until it found "Survey"and thenin a subfolder called "Beginner".




      Screen Shot 2016-11-08 at 4.21.08 PM.pngScreen Shot 2016-11-08 at 4.22.58 PM.png



      I know just enough about file paths to get into trouble.

      Any pointers?



        • 1. Re: Script - Specify Output File Path questions

          Oh, and script needs to run on MAC and PC....

          • 2. Re: Script - Specify Output File Path questions

            Looks like you are going to need to learn more about file paths.


            There's a function that will give you the precise file path to the current FileMaker file's location. with a bit of "surgery", you can tack on one more file folder name to that path to get to Site Survey. Let's start with that as this is the simplest option of those that you've listed.


            Set Variable [$Path ; Value:

               Let ( [ fp = get ( filepath ) ;

                         ln = length ( fp ) ] ;

                         left ( fp ; position ( fp ; "/" ; ln ; -1 ) )

                  ) & "Site Survey/Lables.xlsx" ]

            Export Records [no dialog ; $Path ;...


            you type the name of your variable without quotes directly into the dialog for specifying the file.


            If you really want to "hunt backwards" to find a particular folder that might be in more than one location, you'd need to get the assistance of either a system script or a file plug in in order to find this folder.

            • 3. Re: Script - Specify Output File Path questions

              Hey philmfdjunk!


              Yep-- learning more for sure.



              So I had an idea that i would be using the "Get(filepath)" so that makes me feel good



              Since you posted, I edited my post. I had no issue (after removing the / I left in) to get it into the subfolder.


              I'll work on going "backwards," your variable makes I think enough sense to get close. I'll report back as soon as I get it... or give up



              As always... I appreciate your help!



              • 4. Re: Script - Specify Output File Path questions

                To just get your first try to work, get rid of the initial /

                So, file:Site Survey/Labels.xlsx


                philmodjunk is almost correct, except that Get ( FilePath ) gives a leading 'file:', and you need to change that to either 'filemac:' or 'filewin:'; that's easy enough to do in the Let statement, using Get ( SystemPlatform ).


                I always prefer to calculate the path I'm going to export to as a variable (as Phil has done). While I prefer to use a complete path (actually, I have the free BaseElements plugin, which allows the user to choose a folder), the relative path should work OK for you.

                • 5. Re: Script - Specify Output File Path questions

                  You do not need to change to filewin or filemac. file: works just fine and is cross platform compatible so it saves you the trouble of checking for platforms before assigning filewin: or filemac:

                  • 6. Re: Script - Specify Output File Path questions

                    You're right, it works fine. And here I've for years been writing in that extra bit to comply with the examples given in the Specify Output File dialog. Learn something new every day, thanks.