9 Replies Latest reply on Oct 10, 2011 1:34 PM by disabled_JackRodgers

    Open File dialog box - select default folder

    mattb

      Title

      Open File dialog box - select default folder

      Post

      Is there any way when the Open File <unknown> script step is issued that the dialog box can always open showing the contents of a default folder of one's choice?  Instead of always opening up on the OSX Documents folder? 

      Matt Bloomfield

        • 1. Re: Open File dialog box - select default folder
          sunmoonstar.13

          Instead of Open File <unknown>, try this:

           

          Open URL [ No dialog ; "C:\Users\Matt\Documents" ]

           

          Replace the blue text with the full path to the relevant folder.

           

          Nick

          • 2. Re: Open File dialog box - select default folder
            mattb

            Hey Nick -

            That's a really clever idea and looks like it would work on a source-code version of the app.  But I'm building commercial software which means it has to be distributed in compiled form and whenever a compiled USR file is chosen from an OS window, it just launches the FMP runtime engine which always starts up with the designated "primary" file.  So it looks like I'm stuck with Open File <unknown> to open user-created files on machines that don't have FMP.

            What's perplexing to me is the mechanism by which this Open File window defaults to a folder.  It seems to default to Documents (I'm on a Mac) at first but now it's defauting to my chosen folder.  However I don't know what I did to "achieve" this or whether I can rest assured that it will behave the same way on other people's computers...

            Matt

            • 3. Re: Open File dialog box - select default folder
              sunmoonstar.13

              What's perplexing to me is the mechanism by which this Open File window defaults to a folder.  It seems to default to Documents (I'm on a Mac) at first but now it's defauting to my chosen folder.  However I don't know what I did to "achieve" this or whether I can rest assured that it will behave the same way on other people's computers...

               

              From observing the behaviour of it, the Open File dialog seems to default to the last window/folder from which a file was opened.

               

              I used to use the Open File <unknown> step attached to a button in my main database, as a means of opening other FMP files that were all kept in the same folder. But I got sick of opening files from a dialog window, so instead I created a Custom Menu and added the "Open Favorite" menu item to it. Then I just added my FMP files to the Favorites list and, voila, I now have a dedicated menu for opening my FMP files. Maybe this would work in your own solution?

               

              Nick

               

              • 4. Re: Open File dialog box - select default folder
                mattb

                From observing the behaviour of it, the Open File dialog seems to default to the last window/folder from which a file was opened.

                This seems to be true in the FMP development environment.  But it's less consistent when invoked from a compiled app, I've found.

                I used to use the Open File <unknown> step attached to a button in my main database, as a means of opening other FMP files that were all kept in the same folder. But I got sick of opening files from a dialog window, so instead I created a Custom Menu and added the "Open Favorite" menu item to it. Then I just added my FMP files to the Favorites list and, voila, I now have a dedicated menu for opening my FMP files. Maybe this would work in your own solution?

                Nope, because it's a writing program where users are always creating different files and then needing to retrieve them, so the Favorites list can't be stuffed in advance.   

                • 5. Re: Open File dialog box - select default folder
                  FentonJones

                  If you can use AppleScript (which is on every Mac), this will open only FileMaker files, with the Desktop as the default folder for the choose file dialog. But you can reset that dynamically, if you want, using values from a field.

                  propertydefaultFolder : path todesktop

                  setmyFileto (choose fileof type {"FMP7"} with prompt "Choose a FileMaker File to Open" default locationdefaultFolderwithoutinvisibles)

                  tellapplication "Finder" toopenmyFile

                  • 6. Re: Open File dialog box - select default folder
                    mattb

                    I toyed with the Applescript method a bit, but again it's the same issue with USR files created by a compiled FMP app.  I'm sure this method works with FP7 files in the development environment but in my attempts the Applescript method didn't work with the FMP runtime - kept on getting an error  "User interaction not allowed". 

                    • 7. Re: Open File dialog box - select default folder
                      hbrendel

                      What you need is the Troi File Plug-in.

                      • 8. Re: Open File dialog box - select default folder
                        FentonJones

                        AppleScript in general works with runtimes, with types of files other than FileMaker. But you are right, this particular command, "open" a FileMaker file, does not. The runtime cannot "open" external FileMaker files. I don't think you can get around that. Sorry I did not really pay attention to the "runtime" part of the post. 

                        What is weird is that the AppleScript I posted earlier does not work in plain FileMaker either, to open FileMaker files (other kinds of files are fine). There is no error, but nothing happens. It seems FileMaker is touchy about this. What does work is to split the AppleScript into 2 separate Perform AppleScript commands. In the first, set the chosen file's path as text into a global field. Then use the "Finder" to open the file path.

                        • 9. Re: Open File dialog box - select default folder

                          Use the above mentioned Open Url with $$_folder. Then decide how to get the folder path into the variable. The user could select their own default folder this way. Another method is to have the user insert a file into a container field from the folder they want to use. This does not change the file in any way and they should choose a harmless file. The record can be deleted afterwards.

                          Now use getastext(containerfield) to get the path name and you have everything you want for your Open URL.