3 Replies Latest reply on Feb 9, 2012 1:23 PM by philmodjunk

    Exporting a container field

    FileMakerNovice

      Summary

      Exporting a container field

      Product

      FileMaker Pro

      Version

      11

      Operating system version

      Mac 10.7

      Description of the issue

      Hello,
      I can't seem to figure this one out.  I have a container field that I'd like the user to double click on to open.  This field will have multiple file types.(pdf, word, pages, etc)  I currently have:

      Steps to reproduce the problem

      set variable[$path; Value:Get(TemporaryPath)]
      Export Field Contents [resume; file:$path:/"temp";Automatically open]

      When I double click on a png, it works fine but .pages does not.  It appears to not be saving the extension.

      Expected result

      I would like to double click on a file and it open.  I'd like the file to be temporary and the user never have to delete it.

      Actual result

      PNGs open in preview but .pages files do not.

        • 1. Re: Exporting a container field
          philmodjunk

          double clicking a field (unless you have a very creative script) will not perform a script, but double clicking a container field can automatically open the file inserted into the container field if Insert File with the store a reference option was used.

          It could be that you have set up your container field as a button and then the first click of your "doubleclick" is performing your script.

          In your script, you specify a file name "temp" but do not include an extension so you are correct that your current expression

          Right ( YourTable::Resume ; 4 ) will extract the file extension of the inserted file. I believe that will work with both by reference and non "by reference" files whether inserted as a file or a picture.

          Then you can use this as your $path calculation:

          set variable[$path; Value:Get(TemporaryPath) & "temp" & Right ( YourTable::Resume ; 4 )]
          Export Field Contents [resume; file:$path ; Automatically open]

          • 2. Re: Exporting a container field
            FileMakerNovice

            Sorry, I did not mention that this is on Filemaker Server so only saving a referenced value is not an option.

            I do like your thinking on the right() function.  This would not work with only 4 characters due to ".pages" being 6 characters.

            I just attempted to do your suggestion but changed to 6.  This, as expected works great with .pages but .pdf also extracts the last 2 characters of the file name.  Is there any way to just extract the extension?  I am considering just extracting the whole filename.  Instead of Right(), how would you extract the whole filename from the container field?  How/when is the temp folder emptied?

            • 3. Re: Exporting a container field
              philmodjunk

              Sorry, I did not mention that this is on Filemaker Server so only saving a referenced value is not an option.

              you can have referenced container fields with files hosted by server, but care must be taken in how you configure your system as the folder they are stored in must be shared and mounted on each client machine with a file path that matches the reference in the container.

              As a windows user, all extensions are 3 characters so I didn't consider the possibilty of more characters.

              You can use the position function to find the last "." and get all text to the right of it.

              Let ( [ c = Yourtable::resume ) ; L = Length ( Getastext ( c ) ) ]; Right ( c ; L - Position ( c ; "." ; L ; -1 ) ) )

              A similar function, looking for the last "/" should return the file name.