1 2 Previous Next 19 Replies Latest reply on Nov 30, 2011 10:35 PM by Fagreement

    Get URL from container

    Fagreement

      Title

      Get URL from container

      Post

      I have a silly question:

      I have a containers where i insert images by reference.

      I want to make a script to open the url (image) of the selected container.

       

      in brief:

      how can i get the url of an image inserted in a container

      how can i open it

        • 1. Re: Get URL from container
          philmodjunk

          Container fields do not store URLs so these would be FilePaths, not URL's. (The format of a file path and how you use it is different than that of a URL.)

          GetValue ( containerField ; 3 )

          Will extract the filepath if you inserted the image file with insert picture.

          GetValue ( containerField ; 2 )

          will extract the filepath if you used Insert File.

          You can use either GoTo Field [Select ] or Export Field Contents to open the inserted file.

          Go To Field is the functional equivalent of double clicking your container field. It causes FileMaker to interact with your operating system settings to find and open the file with whatever application is associated as the default application to open a file of that file type.

          Export Field Contents copies the File to a location you specify and has an option to open the file when it does so.

          • 2. Re: Get URL from container
            Fagreement

            thanks a lot, i'll try it

            • 3. Re: Get URL from container
              Fagreement

              hi

              the GetValue ( containerField ; 3 ) doesn't work, i replaced "containerField" with the related column it return null value.

              the image is insert with insert picture !

              • 4. Re: Get URL from container
                philmodjunk

                Was it inserted with the "store a reference" option?

                There is no file path stored in the container field to extract unless that option was specified when inserting the picture file.

                • 5. Re: Get URL from container
                  Fagreement

                  i use store ref and GetValue ( containerField ; 3 ) => it works, it return imagewin:c:/design/picture name.png

                  now to open the file it doesn't work:

                  i used export field contents(field where i insert the image by ref; file:GetValue ( photo:photocontainer; 3 ))

                   

                  nothing happen

                  • 6. Re: Get URL from container
                    philmodjunk

                    You have to manipulate some details of the file path to get it into the right format and the File Reference box cannot evaluate expressions such as GetValue ( ).

                    Instead, use set variable to assign the filepath in the container field to a variable, then put the name of the variable inside the file reference dialog instead of the getvalue expression.

                    I don't think ImageWin: will work here. Try and see if you want to experiment, but I suspect that you'll need to replace ImageWin with "File:" in the filepath you put in the variable before it will work for Export Field Contents.

                    • 7. Re: Get URL from container
                      Fagreement

                      unfortunaltely doesn't work:

                      set variable [$$filepath, "filewin:/"  &  Right( GetValue ( Photo::PhotoContainer; 3 ); Length ( GetValue ( Photo::PhotoContainer; 3 ))-10)]

                      export field contents(field where i insert the image by ref; $$filepath)

                      i have the following message:

                      the file ...could not be found...

                      and after the executio of the script my image on the disk disappear !

                      • 8. Re: Get URL from container
                        philmodjunk

                        You should export to a different location and just extract the file name from the container field. (Sorry, but with the intervening week end, I missed that detail earlier today.) By exporting a file to the location where it is already located, you overwrite that file and this is what is making it disappear. (and with the file deleted like this it is now "not found" when Export Field Contents attempts to open it.)

                        Try this instead:

                        SetVariable [$FilePath ; value:

                        Let ( [ path = GetValue ( Photo::PhotoContainer; 3 ) ;
                                  L = Lenght ( path ) ;
                                  F = Right ( path ; L - Position ( path ; "/" ; L ; -1 ) ) ] ;
                                  "file:"  & Get ( TemporaryPath ) & F
                              ) // let

                        ]

                        Note that I am using "File:" not "FileMac:" or "FileWin:" this makes it an expression that should work on both platforms without having to test for the current platform and thus make this calculation more complex than it already is. Get ( TemporaryPath ) will return a valid path on both platforms and you do not have to delete files from this location aftwards to keep the files from building up on your hard drive.

                        • 9. Re: Get URL from container
                          Fagreement

                          yes it works, it is exported to the temp folder but i want that the script open it automatically

                          • 10. Re: Get URL from container
                            philmodjunk

                            In the export fields step, there's a check box to click that will specify that the exported file be opened automatically. You'll find this in the Specify Output File dialog.

                            • 11. Re: Get URL from container
                              Fagreement

                              yes, already checked, but it not opening the file!

                              • 12. Re: Get URL from container
                                philmodjunk

                                It should. It does on my system.

                                Make sure that exactly the same variable is specified in Export Field Contents as you have in the Set Variable step. Even one letter different or using $ in one and $$ in the other will keep this from working.

                                If you have FileMaker Advanced, use the data viewer to check to see what value is stored in your variable. If You do not have advanced, add a show custom dialog to your script and set it to display the contents of your variable. In your examples, you used a global variable: $$filepath where I used a local variable: $FilePath in mine. Either work in this script as long as it's the same exact variable (one or the other) in both script steps.

                                • 13. Re: Get URL from container
                                  Fagreement

                                  sorry again,

                                  this is the content of $$filepat that i used it in export field

                                  file:/C:/Users/wisso/AppData/Local/Temp/S10/1299678965_inventory_categories.png

                                  automatically open is checked

                                  even if i do edit/export field content with auto open from the menu it doesn't work

                                  question: the first argument of the function export field => what does it mean exactely?

                                  • 14. Re: Get URL from container
                                    philmodjunk

                                    question: the first argument of the function export field => what does it mean exactely?

                                    The first argument should be the name of the container field from which you plan to export/open the image file.

                                    1 2 Previous Next