advertisement
Forums

The Forum is sponsored by 
 

AAPL stock: Click Here

You are currently viewing the Tips and Deals forum
FileMaker 7: scripted export from container fields
Posted by: Greg the dogsitter
Date: December 18, 2005 04:41PM
I have a database, of which one field is a container field. In this case, this field contains jpegs.

I want to have a script that, among other things, transfers each jpeg from the database to a particular local folder. The name of the exported file should match the name of the original jpeg, which is apparently stored within the database when the image is imported.

The only way I can figure out to do this in one step involves a calculated Applescript to handle the renaming. While I've done that before, it just seems very clumsy.

Any other alternatives?

GtDS
Options:  Reply • Quote
Re: FileMaker 7: scripted export from container fields
Posted by: TheTominator
Date: December 18, 2005 05:37PM
Its very tricky. I don't have an answer for you.

I'd like to do something similar and that is to create a html document for the record and include an IMG tag to a (newly exported) photo that was originally in a container field.
I can generate the html document simply enough via the Export to XML feature and select a customized XSLT file. The image is the hard part.

In FM 8, there is a new scriptable command called "Export Field Contents...". When used interactively, it opens up a Save dialog with the original filename provided as the default. This supports your assertion that the filename is stored internally when the file is imported. If the image entered the container field via cut and paste, the filename is lost and Untitled.pct (on Mac) is prompted for the filename.

Additionally there is something inherently unstable about the solution of exporting the contents of a Container field into an image file. Aside from tightly controlling data entry, there is no way (that I have found) to ensure that the Container field contains image content.

The best solution may be to use a third-party plug-in. I'm reluctant to use that method for my project.



Edited 1 time(s). Last edit at 12/18/2005 05:53PM by TheTominator.
Options:  Reply • Quote
Re: FileMaker 7: scripted export from container fields
Posted by: Greg the dogsitter
Date: December 19, 2005 08:32AM
Tom, you were supposed to say, "Yes - there's something you've overlooked." :-(

The Export Field Contents bit exists in 7, too, but I don't know if there's been any sort of update in FM 8. I got real hopeful when I did this:



Clever, right? Specify a folder/directory, and the container should export to that location!

No.



Bummer.

GtDS
Options:  Reply • Quote
Re: FileMaker 7: scripted export from container fields
Posted by: TheTominator
Date: December 19, 2005 08:55AM
Greg the dogsitter Wrote:
-------------------------------------------------------
> Tom, you were supposed to say, "Yes - there's
> something you've overlooked." :-(

That would have been great. I wish I could have said that (and been justified in saying that).

> The Export Field Contents bit exists in 7, too

Sorry. I'd forgotten. I think I overlooked it in version 7.

> Clever, right? Specify a folder/directory, and the
> container should export to that location!

That was a good idea.

There does not appear to be a native solution. Short of acquiring or writing a plug-in for saving the contents of a container, the best solution may be to Export Field Contents to a specific file (e.g. file:ExportedImage.jpg) and then renaming that image using AppleScript or DOS Shell as appropriate. You can construct the AppleScript uniquely each time as a calculation. The exact path to the file saved with "file:ExportedImage.jpg" can be found with this calculation.


Case(

Get ( SystemPlatform ) = "-2"; /* Windows 2000 or Windows XP */
Substitute(Substitute(Get(FilePath);Get(FileName) & ".fp7"; "ExportedImage.jpg"); "file:/"; "file:///");

Get (SystemPlatform) = "-1"; /* Mac OS X */
Substitute(Substitute(Get(FilePath);Get(FileName) & ".fp7"; "ExportedImage.jpg"); "file:/"; "file:///Volumes/");

""
)

I created this to determine the path to the possibly user-specified XSLT file when using the Export script step so the format is engineered to fit the syntax needed there. You can certainly adapt it to meet the syntax needs of (POSIX) AppleScript file specifiers.


Edit: I forgot about a flaw in the above equation. Since it uses a Substitute() to remove the database filename from the end of the path, if one of the directories in the path has the same name as the database solution then the path will get messed up. For example /Volumes/Macintosh HD/Users/GtDS/Documents/CoolProjects/ImageExport/CoolProject.fp7 will get mangled since Get(FileName) will return "CoolProject" and that string will be substituted in the foldername CoolProjects.



Edited 1 time(s). Last edit at 12/19/2005 09:10AM by TheTominator.
Options:  Reply • Quote
Re: FileMaker 7: scripted export from container fields
Posted by: TheTominator
Date: January 23, 2006 04:26PM
I found another useful piece of information. It was in a new book called "FileMaker Pro 8: The Missing Manual."

Do this in a calculation:

GetAsText(ContainerField)

and it will give you what it knows about the contents of the container field.

For a copy and pasted image, it will be "?" as it has no information.

For a container filled by Insert Picture (not a reference) it will give the filename.

For a container filled by Insert Picture (is a reference) it will give something like:
size:327,184
image:../../../Pictures/image.jpg
imagemac:/Macintosh HD/Users/theuser/Pictures/image.jpg

For referenced files it will give:
file:../../../Downloads/TheDoc.pdf
filemac:/Macintosh HD/Users/theuser/Downloads/TheDoc.pdf


Up until now, I didn't know how to access the original image or document's filename.
And I didn't have a method to find out if the container contained an actual image versus a movie, sound, or file.



Edited 1 time(s). Last edit at 01/23/2006 04:52PM by TheTominator.
Options:  Reply • Quote
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 295
Record Number of Users: 52 on November 20, 2014
Record Number of Guests: 2330 on October 25, 2018