Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6230 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello,

I read all posts (at least I think I did...) regarding images in container and haven't found the answer to my problem.

I added a reference image to a db in a container using a calc. (works fine). Use same calculation to "update" or "refresh" all existing records using Record --> Replace Field Content (nice trick that work beautifully).

Now I am trying to find all records that do not have an image associated with their record. Using a calc. text field I thought on using the container content but it only displays the three lines of info when imported not when referenced (only the path shows). I used unsuccessfully IsEmpty, IsValid and IsValidExpression to get a (false) return when container show no image (file not found (filename)). But all records return (true) whether or not the file has been found.

A suggestion would be greatly appreciated.

Philippe

Posted

Yes, my experience is that a calculation to show a referenced file produces the same result when you use GetAsText() whether the file is actually there or not. I've found a few ways to find out.

1. Run an AppleScript in a Perform AppleScript step. Create a calculation (text result) to produce the standard AppleScript syntax path, and use the command: exists file "full Mac path"

You can trap for it being missing, then set either a global or regular number field to the result. (Simplest is if said field is on the current layout.) Example:

tell application "Finder"

if not exists file "Macintosh HD:Library:WebServer:Documents:fm_MC:style.css"

    set theError to 1

else

    set theError to 0

end if

end tell



if theError is 1

   set cell "_gError" to 1

end if

2. Another method, and I think the only one that can produce a result in a calculation (unstored) without a script, is to use a plug-in that can check files. Troi File has a GetFileSize() function you can use.

3. You could use FileMaker to try and Insert Picture by reference, using a script Variable to hold the path. You could do this into a global field. If it failed you'd know the file was missing. This would work, but might take longer that the two methods above.

Posted

Yes, my experience is that a calculation to show a referenced file produces the same result when you use GetAsText() whether the file is actually there or not.

Hi Fenton

is that a Mac thing ?

Because:

Case(

IsEmpty(GetAsText ( container ));1;

0

)

works on Win and gives 1 if the container is empty.

Posted

Hello Daniele,

Nope it's not a Mac thing. Your calc works on Mac as well... if the container is empty !

But in this case the container is not empty since it contains a calc and in this case "0" is returned whether the file is missing or not.

The only thing that shows a missing file is the error: "The file cannot be found: " showing in the container.

Philippe

Posted

Use this calculation in a field Case(container= 0 ;"Yes") and then either search for the Yes, or =

HTH

Lee

Posted

There is a big difference between Insert [x] "As reference only" and Insert with that unchecked (embed). We are talking about referenced image files, NOT embedded images. When you Insert as reference only, GetAsText() is the SAME whether the file is still there or not; it still retains the same info of the original file (which was there at one time).

There is NO way (that I know of) to tell the difference using IsEmpty(), which is always not empty for this problem, or Length(), which is 0 for referenced pictures anyway, whether they're there or not. Which is why I offered those esoteric methods. If you know better, then please tell; but these simple tests do nto solve this problem.

plh212 has already said this also, in both of his posts. It is important to pay attention to details when dealing with images and files, because there are several possible situations.

Posted

When you Insert as reference only, GetAsText() is the SAME whether the file is still there or not; it still retains the same info of the original file (which was there at one time).

Seems kind of dumb to me. Wonder why FM chose to do that?

Posted

Well, it does seem a little odd that FileMaker knows to say (pseudo), "This file isn't here anymore," but has no way for you get that status yourself. Likely it really doesn't know until it tries to render the picture, and that info is not available to the calculation engine, because of timing or separation, or something else we don't understand about the inner workings. Would be nice. I'm hoping later versions of FileMaker have some simple file-handling ability (exists would be a start).

Posted

Wow, I never use reference images, so I hadn't ran accross this problem.

Has anyone reported this to FMI? I searched the Tech Articles, but didn't turn up anything.

Lee

Posted

Thank you all gentlemen for arriving at the same conclusion than I did: "Seems kind of silly to me that FM would know and acknowledge the image is not there but you cannot use this info in any simple way."

I will now try the get-around suggestions by Fenton... must admit I am 100% new to Applescript and don't know exactly how to handle this, but I will give it a try. Thank you Fenton for your precious help !!

Posted

Hello Fenton,

If I understand your post correctly I would have to create an AS for each and every single record since the name of the .jpg is based on the SKU's of the record. My actual calc takes info from the SKU and change for each record. How to incorporate in an outside script (AS) a variable piece of information ?

It looks like the Troi solution would work fine but I am trying to avoid shelling out $75.00 for something I feel should be part of FM !

Thank you,

Philippe

  • 1 month later...
Posted

I have run into this problem myself, and had to do an unfortunate work around: have another field for each container, and use that to indicate when an image is not showing up, e.g. set to either Yes or No. In my container calcs, I check the value of that field, and if it is set to Yes, go to the path for the file, otherwise go to a placeholder image.

Of course, the problem with that is that you have to look at every record's image to set the field.

Posted

Run this is a Perform AppleScript step. To do the found set you'd just put it in a loop, with Go to Record [ Exit after last, Next ]; just like any other loop.

Like all Loops, you should Freeze Window and run in View as Form; much faster than View as List.

You would need to have, on the current layout, the fields:

theImage; a container field

ExistsAS; a text field

Or adjust the AppleScript below for your own field names. You could have it set a 1 instead of "missing" if you prefer. You could clear the field in FileMaker first if you prefer (then you wouldn't need the else below to clear it.

set theFile to ""

	

	tell current record of current layout of window 1

		set theFile to (get data cell "theImage") as string

		

		tell application "Finder"

			set existTest to exists file theFile

		end tell

		

		if existTest is false then

			set cell "ExistsAS" to "missing"

		else

			set cell "ExistsAS" to ""

		end if

		

	end tell

Posted (edited)

It looks like the Troi solution would work fine but I am trying to avoid shelling out $75.00 for something I feel should be part of FM !

I agree that we should have basic file manipulation in FileMaker (someday). There are a couple of new plug-ins which have come out recently that do much of what Troi File does, but are much cheaper.

But I don't think any of them have all the features of Troi File; such as: writing to files, appending to files, changing encoding, switching line endings.

Unless you go the whole command line kind of thing, or use something like SmartPill_PHP. So look around, there's several possibilities.

Dacon FileFire Express (newest, only $29, wins on price)

http://www.dacons.net/fmplugins/filefireexpress/prodinfo/

Productive Computing File Manipulator ($40)

https://www.productive.cc/pci_cart/FMPro?-DB=PCSC_Products.FP5&-Format=catalog.htm&-Lay=CGI&ID_No=56&-Find

Edited by Guest
  • 10 months later...
Posted

Hey Guys:

I use a very simple effective solution that works beautifully for what you need even if the image is just referenced.

Use the count(field) function and just replace "field" with the container field (note B) I have only checked with container fields not with calc field with container result).

If the image referenced by the container field exists, the count will be 1, otherwise it will be 0!

Posted

I must be missing something, because it doesn't work for me. I have a Image field (Container) that shows "This file cannot be found: picture.jpg", and an unstored calculation = Count (Image) that returns 1. Are you sure your images are referenced only?

Posted

I am so sorry...you are correct...your response made me remember that my solution worked only in cases when someone had used the "delete" key over the picture to erase it. If that happened then the count function the count function would say (0) instead of (1). Therefore & unfortunately it does not really solve at all the problem in the topic. Sorry about that.

This topic is 6230 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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