December 2, 201510 yr I have an instance where a container field is occupied by an image of unknown type. It might have been inserted or pasted in ... or imported. It will be accepted for further processing only if it's a PNG. How can I easily determine that? When I look at the actual header bytes of the file (after exporting it), "PNG" is clearly visible. Yet I wasn't able to get those first 4 bytes with a Left ( text ; 4 ) directly from the container. Is there a way to do that? Thanks in advance for any help. Edited December 2, 201510 yr by K1200
December 2, 201510 yr https://www.filemaker.com/help/14/fmp/en/html/func_ref1.32.15.html GetContainerAttribute to the rescue! Edited December 2, 201510 yr by Kris M
December 3, 201510 yr Author Thanks for the response ... but I had looked for some definitive image attribute and couldn't spot one. Did I miss it? filename seems to only apply to inserted files and not to pasted images. But I'll try some additional searches.
December 4, 201510 yr What do you get when you put this in Data Viewer? RightWords ( GetContainerAttribute ( yourTable::yourContainer ; "filename" ) ; 1 ) Note - don't use Get ( FileName ) ... type the literal text just as it shows "filename" ... It works when I drag an image into the container and also works when I use Insert. Edited December 4, 201510 yr by LaRetta
December 4, 201510 yr On Thu Dec 3 03:57:43, K1200 said: filename seems to only apply to inserted files and not to pasted images. IIRC, a pasted image would never be PNG. But this might be outdated.
December 4, 201510 yr I can copy a png and paste into container and it works in same wayl, at least on El Capitan. I also imported and got same results. :-)
December 5, 201510 yr I need to correct myself. I forgot about the word separator behavior in FM where 'alpha-dot-alpha' is counted as one word. There are many ways to get the extension from the file name ... here is one: Let ( name = GetContainerAttribute ( yourTable::yourContainer ; "filename" ) ; RightValues ( Substitute ( name ; "." ; ¶ ) ; 1 ) ) or to eliminate the trailing return: Let ( name = Substitute ( GetContainerAttribute ( yourTable::yourContainer ; "filename" ) ; "." ; ¶ ) ; GetValue ( name ; ValueCount ( name ) ) ) Edited December 5, 201510 yr by LaRetta
December 5, 201510 yr Author @LaRetta: Thanks. That does work. But in Windows on my PC, I've found that a simple GetAsText also returns the file's name, just like GetcontainerAttribute. I haven't tested all file types, but it seems to work for PNGs. Thanks for the other responses, also.
Create an account or sign in to comment