6 Replies Latest reply on Feb 6, 2014 10:39 AM by AlexandraFaidiga

    Opening Pictures in Container Fields

    AlexandraFaidiga

      Title

      Opening Pictures in Container Fields

      Post

      Hello, I am very new to Filemaker and I have a problem that is probably easy to solve for someone with a lot of experience with FM. How can I double-click a picture in a container field and have an enlarged version of the picture in a new window? Or even within the database, and have it go away when you move your cursor perhaps? Thank you very much!

        • 1. Re: Opening Pictures in Container Fields
          philmodjunk

               It may or may not be possible. You may have to use a single click instead. wink

               If you:

                 
          1.           Use a container field that does NOT have external storage specified.
          2.      
          3.           The container field on your layout where you want to double click it has NOT been optimized for external storage.
          4.      
          5.           Inserted the file with the "Store a reference" check box selected.
          6.      
          7.           Inserted the file with the Insert File option (and then you can't see the image in the field, only an icon for the file)
          8.      
          9.           Then double clicking the file will open the original file with the application specified by your computer as the "default application" for that file type.


               But you can use Export Field Contents to export and open a copy of any file inserted by any method into any container field. You can write a script to do this and set up a button (even the container field itself can be set up as a button) that performs this script to open the copy of the file with a single click.

          • 2. Re: Opening Pictures in Container Fields
            AlexandraFaidiga
             Would it be possible for you to show me what the script would be? Like I said I have no training in FM and what you described with clicking the image and having it open a copy of the file is exactly what I need it to do. I just have no clue how to write scripts.
            • 3. Re: Opening Pictures in Container Fields
              philmodjunk

                   For more info on the various parts of what I am about to script, see: Exploring the use of a $Path Variable in Scripts

                   A button set up with the Perform Script option can perform this script. Substitute your table:::field names for mine:

                   Set Variable [ $FileName ; //put calculation listed below here ]
                   Set Variable [ $Path ; Get ( TemporaryPath ) & $FileName ]
                   Export Field Contents [ YourTable::YourContainerField ; “$Path” ; automatically Open ]

                   This calculation extracts the file name from any container field regardless of storage options, insertion/import method and whether or not "store a reference" was selected. The only case where it fails is if you use FileMaker 11 on windows to either drag and drop a file or use Insert Object--an option no longer available in newer releases:

                   Let ( [ T = If ( LeftWords ( YourTable::YourContainerField ; 1 ) = "remote" ;
                                          GetValue( YourTable::YourContainerField ; 1 ) ;
                                          GetValue ( YourTable::YourContainerField; ValueCount ( YourTable::YourContainerField) )
                                         ) ; // If
                             L = Length ( T )];
                             If ( LeftWords ( T ; 1 ) = "remote" ;  Right ( T ; L - 7 ) ; Right ( T ; L - Position ( T ; "/" ; L ; -1 ) ) )
                           ) // Let

                   And some new users have trouble with Set Field:

                   When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

              • 4. Re: Opening Pictures in Container Fields
                AlexandraFaidiga

                     The only thing that I am having trouble understanding is the two SetVariables and how they relate to those instructions for SetField. There are no two specify buttons for SetVariable-- only one. I've managed to get as far as the screenshot shows. The last bit is correct as you've written it. 

                     But I don't understand; do you mean I should have a SetVariable within the other SetVariable? I guess I just don't know what goes where. Is this all one long line? Or do I have it right with the ExportFieldContents separate? Thanks again for your help.

                      

                • 5. Re: Opening Pictures in Container Fields
                  philmodjunk

                       Never mind the info on set field. It does not apply. But your current script does not assign the correct value to either $path or $filename. My example script first gets the name of the file from the container field and assigns it to $Filename. The second set variable step combines the text in $filename with the file path to the temporary folder. 

                       It is possible to combine the two calculations into one expression and then use just one variable. I chose to use two so that I could break it down into less complex steps. 

                  • 6. Re: Opening Pictures in Container Fields
                    AlexandraFaidiga
                     Awesome! I got it, thank you so much!