Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Detecting broken image references

Featured Replies

I have a photo database that is a reference only type for the image. During the editing of the photos themselves sometimes the reference numbers are changed and a new photo of the previous number needs to be made. I detect no image records with a flag testing the image field with the isempty function. However when the reference is broken the image field is not empty. I tried testing the text content of the image field and it lists the path with no reference to the lack of the image being found. Does anyone know a way to detect when the referencecannot find the previously defined image? The message in the container field reads "The file cannot be found:xxxxxx.jpg". If I can find a way to get that text it would be easy.

Thanks

Rod

If you're on a mac, there should be an applescript based solution...

It kicks up an error when you try to copy it. "Picture" is the Container field:

Set Error Capture ["On"]

Copy [ "Picture" ]

If [ Status(CurrentError) <> 0 ]

It's busted

End If

I don't know how this would fly in a large file, as you'd be loading up the clipboard over and over. Defintely want to backup your files before running; and only run this file.

As jfmcel says, better options exist on Macs. This works in 6. Put in a Perform AppleScript [] step.

_gFileRefPath is a global text field.

----------------------------------

Set Field [ _gFileRefPath, "" ]

Exit Record/Request*

Perform AppleScript [

try

set cell "_gFileRefPath" to (get data cell "Picture") as text

end try

]

If [ IsEmpty (_gFileRefPath) ]

It's busted

End If

--------------------------------

It doesn't work in 7, because it still returns the path when the image is gone. But this works; it asks the Finder to check that the file is still at that path.

------------------------------

set thefile to ""

tell current record of current layout of window 1

try

set thefile to (get data cell "PictAsRef") as string

end try

tell application "Finder"

exists file thefile

copy result to existTest

end tell

if existTest is true then

set cell "InfoAS" to thefile

end if

end tell

  • Author

Fenton, thanks for the detailed help with the applescripts. This app is cross platform, and in FM7, I'm desperately trying to stay away from plugins and apple scripts as I convert to 7 as it will make life a lot easier. I'll try the copy method, the other I wanted to try is the get selected field size to see if that worked, but looks like the most elegant way will not work, that being a calc instead of looping thru the entire photo data base.

Rod

Copy kicks up an error in version 6, but not in 7. I can't think of way to tell if it's there with just FileMaker. Maybe someone does. My personal point of view is that you need such a plug in (or AppleScript) to effectively deal with image files; until the grand day when FileMaker can manipulate files cross-platform (or at least just see if they exist).

So, it appears you must follow the logic of the AppleScript, using a plug-in, such as Troi. GetAsText(container) will contain the file path, which you can then parse out. Troi can tell you if the file still exists at that address.

The file path will be (I think) always the 3rd line of the info. Perhaps better is that it would always be the text after "imagemac:/" (or "imagewin:/"?), which you'd have to get the platform. Then Substitute() to get the separators expected; FileMaker uses forward slashes, Mac uses colons generally, or forward slashes.

  • Author

Fenton, thanks for the in depth and consise help. I'm really frustrated with having to add patch after patch to FM, been doing it for years, tricks, cobbles, work arounds, etc,... nothing new to anyone using this software. I'm being very conservative about adding more of this into 7. FM7 has some nice new features, but quite frankly I'm reallly starting to swing back to 6 based on these issues, the amount of work required to convert an existing solution into FM7 versus the benefits gained is a major issue. Something as simple as finding a broken image link takes this much work to find a work around is just not worth the hassle, as a side note the trial version of this solution I've put out has been totally ragged for the lack of scroll capabilities on Mac platforms and speed issues in general, their complaints are valid, it cuts into their productivity by not being able to scroll and waiting for layouts to refresh. The benefits to the user versus these type basic interface issues just do not make FM7 justibiable.

I will continue to convert this particular solution to 7, but have put a big stop on any further conversions to 7 till I see some improvements.

Again thanks for the help

Rod

Hm, well i found something very strange:

Applescript returns VERY erroneous information for the contents of a container field holding a reference. In the test case the field is "Image" and the Filemaker value is: imagemac:/Cube 1/Users/bfr/Desktop/Untitled36.jpg

Applescript returns something from a completely different drive! It returns the path to the database file.

cell "Image" of current record:

file "Data 2:FMDevcon04 CD:SessionExamples:TEC207Examples Folder:FMP123:Untitled36.jpg"

But when they fix this - or with Filemaker 6 - it should be easy

This works in FM6:

try

Get data cell "Image" of current record

-- result

-- file "Disk:Folder:Subfolder:FileName"

on error errmsg number errnum

-- if it does not exist you'll get:

-- Apple events or Macintosh system error: -43

end try

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.