5 Replies Latest reply on Feb 22, 2011 9:32 AM by AdrieneSmith

    Calculation for a file path resulting in container to display an image

    dbail22@comcast.net

      Title

      Calculation for a file path resulting in container to display an image

      Post

      Is there any calculation that can tell you if the resultant path in a calculaiton field that results in a container finds a file?  I have a database with over 20,000 records which has only 400 records with photos to display.  Using a calculation to a file path for a jpeg image works fine and displays the image when necessary.

      My problem is I need to know if a calculation did result in an image for several reasons including filtering a portal to only show records with a relaed image.

      No calculation I try such as length() getastext() shows any difference.  Is there a calculation that can determine if there will be or does display an image.  A scrip to loop through the images in a folder to load a file and test for an error was WAAAAY to slow and in a few years the recourds could total 50,000 with a few thousand photos.

      Ideas??

        • 2. Re: Calculation for a file path resulting in container to display an image
          dbail22@comcast.net

          Thanks, but I have followed that link and more.  It basically resolves to either a plugin (does not support mac) or a script to load a file and test for an error that takes much much tool long for tens of thousands of records. I had hoped for something as simple as isvalid(field) but no joy there.  This work is for a non-profit animal rescue group so purchasing costly plug-ins is not an option.  Thanks for the response.

          • 3. Re: Calculation for a file path resulting in container to display an image
            FentonJones

            I don't think you need to "load a file" to see if it is there. You may need to use either AppleScript or a free plug-in to see if it is there. The MooPlug on Windows can do this, the ScriptMaster plugin, from 360Works can do this cross-platform (it's in their example file, and is pretty simple). None of these are hard to do, none of them open the file first, so all of them are fast.

            The only catch is that they require an OS syntax file path, not a FileMaker syntax one (which is what the container contains). So you'd need to parse it out, and remove the FileMaker prefix ("file:", "filemac:/", "filewin:/" or "image:", etc.).

            On a Mac, you can use either "vanilla" AppleScript or a Unix shell command. Basically it depends which syntax path you want to figure out. You could do that either in FileMaker itself, as an unstored calculation, or on the fly in the Perform AppleScript step.

            The following would run in a Perform AppleScript step. You would need to pass it the container's FileMaker syntax file path (I just hard-coded it here). It will throw an error if the file is not there, which you can use Set Error Capture ["On"], then Get (LastError) to capture:

            There is a commented line which you'd use instead, in hosted files situations, where the paths are different.

            set fm_path to "filemac:/Macintosh HD/Users/fej/Downloads/vlc-1.1.5.dmg"

            -- hosted files; strip 'file://', add '/Volumes/' to create a POSIX path
            -- set posix_path to ("/Volumes" & ((characters 7 through -1 of fm_path) as Unicode text))

            -- not hosted; do the offset of "/" twice, to remove the FM prefix, then the drive name
            set off_set to (offset of "/" in fm_path) + 1
            set path1 to (((characters off_set through -1 of fm_path) as Unicode text))
            set off_set to (offset of "/" in path1)
            set posix_path to (((characters off_set through -1 of path1) as Unicode text))

            do shell script "test -e " & quoted form of posix_path

            • 4. Re: Calculation for a file path resulting in container to display an image
              RedL

              I need this feature for my application also.  I am not familiar with AppleScrip.  Can you post the result of posix_path and entire shell script for "not hosted" case?

              • 5. Re: Calculation for a file path resulting in container to display an image
                AdrieneSmith

                "I have a database with over 20,000 records which has only 400 records  with photos to display.  Using a calculation to a file path for a jpeg  image works fine and displays the image when necessary."

                This is the part i'm stuck on.  I'm trying to get FM to show an image based on the content of a field.  For example:  if the gender is M, show picture A and if the gender is F, show picture B throughout the database.

                I've only had FM for two weeks so I'm incredibly new to this.  This seems like a simple enough function, I just have yet to figure out how to do it.