1 2 Previous Next 26 Replies Latest reply on Oct 16, 2012 11:22 AM by mattb

    Open File script step

    mattb

      Title

      Open File script step

      Post

      Working with FMP 11 Advanced (Mac)

           I would like to be able to use the Open File script step to open an existing file in the current folder based on a file name stored in a field in the currently open table.  Right now my only choices seem to be Open File <unknown>, which lets the user select a file from a dialog box or Open File <specify>, which opens a predetermined file by name.   It would be handy as in other areas of FMP to specify the filename "by calculation" (i.e. by the file name contained in a field) but I don't see that option here.  How can I do this?

            

           Matt Bloomfield

            

            

        • 1. Re: Open File script step
          schamblee

               I would try using open url

               The filemaker help gives an example of openning a windows file :

          Open URL [No dialog; "file://c:/My_File.txt"]

               I'm sure if you passed the correct mac path that it would do the same as the windows example. 

          • 2. Re: Open File script step
            mattb

                 Interesting suggestion, but it doesn't work for my purposes.  What happens is that it launches the default browser (in this case Safari) and then opens up the file there.  What I'm trying to do is just open up an FMP .USR file in FMP itself (in this case a compiled runtime version of FMP) based on a file name stored in a field in the currently open table.  But I can't do that because the Open File script step requires either specifying a known pre-existing file or having the user make a selection from a dialog box.   So...I'm still looking for a way to do this...

                  

                 Matt Bloomfield

                  

            • 3. Re: Open File script step
              mattb

                   I tried and failed with this method:

                   1)  Assign the file name stored in the table field to a public variable

                   2)  Specify a data source whose parameters are file:$$variable

                   3)  Use the Open File script step specifying this data source

                   I get an Error 100 ("file is missing") when attempting to use this method.

                   Am I totally stuck here?  i.e. there's absolutely no way to open an FMP database except through user choice from a dialog box or specifying a pre-existing file name???

                    

                   Matt Bloomfield

                    

              • 4. Re: Open File script step
                philmodjunk

                     Open URL works on the Windows platform, but I have seen reports here that claim that it does not work on Mac systems.

                     Have you tried using Send Event?

                     I don't know if you can get it to work, but it looks like you can specify the file name and path in a variable that can then be used with this script step.

                • 5. Re: Open File script step
                  philmodjunk

                       Just tested that idea on my Windows Xp system with FMP 12 and it successfully opened a file on my desktop.

                  • 6. Re: Open File script step
                    mattb

                         Open URL opens the default browser when executed from FMP Mac, even if using the "file:"  prefix instead of "http:"  An example of opening an FMP database (which is what I'm trying to do here) is given in the FMP help file using the "fmp:" prefix, but that seems to be specifically for opening an FMP database on a remote machine that can have an IP address of some sort. 

                         I tried the Send Events script step but all that seems to do is open up another instance of the parent application which is not what I want.  In my case the application is already open and all I want to do is specify the name of the FMP database to open without having the user specify the name of the file from a dialog box.  Since this is a commercial application, obviously I can't specify the name of a pre-existing file to open because I don't know it.  I do have the name of the FMP database file sitting in an open table field, and it's really frustrating that I can't apply this crucial bit of data to the Open File script step! 

                         I am using Visual Foxpro still for the Windows version of this same commercial app and it's a total snap there to open a database file from a stored variable.  I've been beating my head against a brick wall in Mac FMP to accomplish the same and now my head is sore.

                          

                         Matt Bloomfield

                          

                    • 7. Re: Open File script step
                      mattb

                           Phil:

                      Just tested that idea on my Windows Xp system with FMP 12 and it successfully opened a file on my desktop.

                           What kind of file?  An FMP database file?  Or a text file?  Or what?  I have Windows FMP and will test it there just to see what it does, but in the end it's all academic because I'm dealing with a Mac FMP application. 

                            

                           Matt Bloomfield

                      • 8. Re: Open File script step
                        philmodjunk

                             I opened an FMP file.

                        • 9. Re: Open File script step
                          mattb

                               Phil:

                          I opened an FMP file.

                               OK, I did my tests and found the following:

                               1)  Windows FMP:  Yes, the Open URL script step does work to open an FMP FP7 file.  Doesn't work on USR files.

                               2)  Mac FMP:  Open URL opens the default browser.  I couldn't find any way to turn the default browser off, even though the FMP help file says the following:

                          If the user has configured the internet system preferences, this script step allows the user to open a URL. Open URL supports http, https, ldap, ldaps, ftp, file, and mailto URL types, using the applications specified in either the control panel or system preferences.

                               I couldn't find any "internet system preferences" on my Mac that had anything to do with a default browser or which application opens which file types.  In my Safari preferences, I could only select some other application for default browswer.  When I set that to Firefox, then the FMP script just opened Firefox instead.

                               Conclusion:  You cannot open an FMP database file using the Open URL script step on Mac FMP.  Period.  Damn.

                                

                               Matt Bloomfield

                          • 10. Re: Open File script step
                            philmodjunk

                                 But I didn't use Open URL. I used Send Event.wink

                            • 11. Re: Open File script step
                              mattb

                                   Phil -

                              But I didn't use Open URL. I used Send Event.wink

                                   Oh...OK.  That sent me into a round of testing Send Event and like your experience, it seemed to work fine on Windows, as far as opening an FP7 file.  It did not work on a USR file though - nothing happened. 

                                   I tried the same thing on the Mac - and yes the Send Event script step did open up an FP7 file, but when I asked it open a USR file, it immediately launched the parent app that USR file was associated with (this didn't happen in Windows) but it ignored the specified file in the script step and instead opened a standard dialog box to choose which file to open on.  So.......frown

                                    

                              • 12. Re: Open File script step
                                Sorbsbuster

                                     Should you not be trying to open the .exe file, not the usr file?  I can use Open URL, with a file name defines in a field, and it correctly launches the runtime.  Windows, sorry don't have a Mac to try.

                                • 13. Re: Open File script step
                                  mattb

                                       Sorbuster:

                                  Should you not be trying to open the .exe file, not the usr file?  I can use Open URL, with a file name defines in a field, and it correctly launches the runtime.  Windows, sorry don't have a Mac to try.

                                       On the Mac, Open URL is total no-go because it always opens up your default browser and tries to open the specified file (or application) from there, even when using the "file:" prefix on the address line.  Windows FMP is "better behaved" - it will open an FMP FP7 database with the 
                                       "file:" address line.   And I believe you when you say it correctly launches the runtime, although I haven't tried that myself yet.

                                       With regard to Send Events on the Mac, and specifically in regard to dealing with an FMP runtime and associated USR files, it doesn't seem to matter whether an "Open Application" or an "Open Document" event is sent, the results are the same:  the Open File dialog box where the user has to pick which file to open.  So, the specified USR file in the script step is just ignored.

                                        

                                  • 14. Re: Open File script step
                                    philmodjunk

                                         Hmmm, and just to confirm, does double clicking the USR file correctly open it? Just making sure here.

                                         I can think of a rather off the wall option you can try if you are interested:

                                         Use Insert Field  File to insert a reference to the file into a container field. Then use either Go to Field [Select/Perform... or Export Field Contents to open the file.

                                    1 2 Previous Next