9 Replies Latest reply on Dec 21, 2008 12:02 PM by satinder

    Script to insert image into container field

    satinder

      Title

      Script to insert image into container field

      Post

      I have 2 container fields in my database. In the first field, called "high res", I insert a high resolution image. In the second field, called "low res", I insert a low resolution image. The image is of the same thing. I want to create a layout using these images as follows:


      If the high res field contains an image, then I want the high res image inserted. If the high res field does not contain an image, then I want the low res image inserted. I'm guessing I need to write a script to do this but I couldn't figure out what script commands to use. I would appreciate some guidance in how to write a script to do this.

       

      Thank you.

        • 1. Re: Script to insert image into container field
          TSGal

          satinder:

           

          Thank you for your post.

           

          One simple option would be to put the high res image field directly on top of the low res image field, and set the field to be see through.  If the high-res image is not there, the low res image will show underneath.

           

          Another option would be to have two identical layouts except for the container fields.  You could then have a script that says:

           

          If [IsEmpty (HiResField) ]

             Go to Layout ["Low Res Layout" ]

          Else

             Go to Layout ["High Res Layout" ]

          End If

           

          -----

           

          If you need clarification for any of the above steps, please let me know. 

           

          TSGal

          FileMaker, Inc.

          • 2. Re: Script to insert image into container field
            davidhead
              

            This is a bit confusing but I think what you already have on some layout is a place where you can insert high and low res images into separate container fields.

             

            I think your problem is that, on another layout, you want to display either the hIgh res image if that exists, else display the low res image.

             

            To do this, you need a calculation field that returns a container result with the following expression:

             

                 If ( IsEmpty ( hiRes ) ; loRes ; hiRes ) 

             

            See how that works for you if I have guessed right about your requirements. ;) 

            • 3. Re: Script to insert image into container field
              satinder
                

              You have guessed correctly.  Thank you for the suggestion.  I will try it and post the result here.


              Satinder

              • 4. Re: Script to insert image into container field
                raybaudi
                  

                Hi David

                 

                [...]

                uLearnIT said:

                 

                If ( IsEmpty ( hiRes ) ; loRes ; hiRes )

                [...]

                 

                another type of calc can be:

                 

                If ( Length ( hiRes ) ; hiRes ; loRes )

                 

                 

                 

                 

                • 5. Re: Script to insert image into container field
                  davidhead
                    

                  another type of calc can be:

                   

                  If ( Length ( hiRes ) ; hiRes ; loRes )

                   


                  Hi Danielle
                  Yes that will work also. There are often a number of ways to check the same thing. However, I think that checking for length is a bit off the track of what you are really trying to ask don't you think? I prefer to explicitly check whether there is something in the field. :) 

                   

                  • 6. Re: Script to insert image into container field
                    raybaudi
                      

                    The Length (  ) function comes on my mind because it returns the approx. Kb of the image and a HiRes one is bigger than a LoRes.

                     

                    So another way can be .

                     

                    If ( Length ( HiRes ) > Length ( LoRes ) ; HiRes ; LoRes )

                    • 7. Re: Script to insert image into container field
                      davidhead
                        

                      That is completely logical and it works fine but I still want to apply the KISS principle - simply test for what you are asking about.

                       

                      As an example, I may want to know how much fuel I have in my car. There are lots of ways I can find that out. The most obvious is to check the fuel gauge. But I could also weigh my car and compare that weight to the known weight with an empty fuel tank. 

                       

                      In this case, you want to know "is there a high res image?". That is exactly what the IsEmpty function tells you. I don't like to use an alternate expression/function where there is one that does the job, even if it works. YMMV.

                       

                      BTW, it may never happen but this could break:

                       

                         If ( Length ( HiRes ) > Length ( LoRes ) ; HiRes ; LoRes )

                       

                      ...when the high res image is inserted as a reference only and the low res image is not a reference ;)

                      • 8. Re: Script to insert image into container field
                        raybaudi
                           "BTW, it may never happen but this could break:

                         

                           If ( Length ( HiRes ) > Length ( LoRes ) ; HiRes ; LoRes )

                         

                        ...when the high res image is inserted as a reference only and the low res image is not a reference "

                         

                        Good point

                        • 9. Re: Script to insert image into container field
                          satinder
                            

                          It looks so simple and straightforward when I read the suggestions but then I always have trouble applying it to my database.  I'm still new to Filemaker so please bear with me.

                           

                          I'm not sure how to incorporate my field names into the suggested scripts.

                           

                          Here is my specific information.

                           

                          Database Name:  Product Catalog

                          Hi Res Image Field:   Image High Res              type = container

                          Low Res Image Field:   Image Low Res            type = container

                          Layout Name:   Minster Catalog Pages 2 x 2

                           

                          Thank you.

                          Satinder