9 Replies Latest reply on Sep 30, 2011 8:16 AM by philmodjunk

    Open a variable defined file in a script



      Open a variable defined file in a script


      Greetings from a 70 year old FileMaker Pro user...

      I have a script that saves a copy of the currently active file. It then modifies the current file (deleted some unwanted records) then saves the file under a different name (defined as $filepath variable). But now... I need help to script a way to Open the saved modified file with a variable and close the first file - or can I first close the current file then Open the modified file using the defined file name?

      When I use "Open File" as a script step, FileMaker Pro insists on requiring the user to type in the file name - NOT what I want the user to do. How do I auto-fill in the file name input window with the previously defined file name? Or is there a different approach needed?

      I'm hoping for an easy and clever set of steps. Sorry, I'm not a sophisticated user of FileMaker


      Thank you for your kind assistance.

        • 1. Re: Open a variable defined file in a script

          You can use Open URL to open the file, I believe...

          • 2. Re: Open a variable defined file in a script

            Dear Phil, (philmodjunk)

            Thank you for your quick reply. I tried to use the Open URL script step with no success. I must have the wrong syntax.
            "Open URL (No dialog; Open with url::Get File"
            whereas Get file is a global calculation "file://desktop:/" & Name
            and Name is a global calculation "My File" (a TextEdit file).

            Thank you for your patience.
            David Summer
            • 3. Re: Open a variable defined file in a script

              That doesn't look like a valid file path to me.

              Here's an expression that worked for me:

              "file:" & Get ( DesktopPath ) & "CheckboxWScrollBar.fp7"

              The file name in quotes was located on my desktop.

              • 4. Re: Open a variable defined file in a script

                So I tried your example script using my data and the result was "Safari can't find the server".

                Here's my script (that doesn't work):

                Open with url::Get File


                Get File is a global calculation field defined as: "file:" & Get ( DesktopPath ) & Name

                In the browse mode: Get File shows up as: file:/Macintosh HD/Users/david/Desktop/My File

                Name: is a global text field defined as: My File (a TextEdit file)

                Where have I gone wrong?


                • 5. Re: Open a variable defined file in a script

                  Get File is a field name? WHere's the name of the table?

                  You should see: Open URL [TableName::Get File]

                  You don't by any chance have:

                  Open URl ["Get File"]

                  do you?

                  • 6. Re: Open a variable defined file in a script


                    Uh oh! My table name is: Open with Url

                    An unfortunate table name choice for my sample script but it shouldn't matter... or does it?

                    It's the only table in my sample data base. Once I get a working script, I intend to modify and use it in my real data base.

                    But to answer your question directly, yes Get File is a calculation text field whose value is defined as:

                    "file:" & Get ( DesktopPath ) & Name

                    Name is a calculation text field whose value is: My File  (a TextEdit file on my desktop)

                    Your thoughts?

                    • 7. Re: Open a variable defined file in a script

                      The trouble is that the function as suggested by Phil only works well on windows and not on MacOSX and the alternative could be using "send event", but that does not work either because one has to assign an application to send the event to and assigning it to Filemaker Pro is not allowed. The only option i can get working is to use "Perform AppleScript":

                      before you can do that you must first determine the (unix)username and put it in a variable:

                      $username = Let([LST=Trim( Substitute( Get( DesktopPath ) ; "/" ; ¶ ) );NR=ValueCount( LST ) -1 ];Substitute ( MiddleValues ( LST ; NR ; 1 ) ; [ ¶ ; "" ] ) )

                      then write the script:

                      $script = "tell application \"Finder\"¶activate¶open document file \"" & $filename & "\" of folder \"Desktop\" of folder \"" & $username & "\" of folder \"Users\" of startup disk¶end tell"

                      (where $filename is the variable with your copied file)

                      now enter $script in the dialog for "calculated script" in the "Perform AppleScript" scriptstep and it should work fine

                      regards, Menno


                      @phil: imho should filemaker inc make it possible to either use the "send event" step to send an event to "self" or apple should make it possible to send a URL to fmp7:// or to file: as is possible on Windows. The tools offered on windows are in this particular issue much eassier than on macosx

                      • 8. Re: Open a variable defined file in a script

                        I don't mean to hijack a thread, but have been trying something similar and having the same issue.


                        @menno - if you wanted to use a path to the server, could you use something like "volumes/server/$filename" rather than trying to get the desktop path of each computer.  Then use a Case function to detect whether the user is on a Mac or windows machine to determine which method to use.

                        • 9. Re: Open a variable defined file in a script

                          @Menno, thanks for the additional info. As I do not currently have a mac system to use, only windows, I was unaware of this difference. I agree that this lack on the Mac side of the fence is unfortunate and leaves room for improvement. However, I'm just a fellow fileMaker user, not a FileMaker Inc representative. You might want to post this comment in feedback or use the Feature Suggestion Form if you have not already done so. (And if you are reading this and agree with Menno, you can click this same link and "chime in". Wink)