Your idea is sound, to create a dedicated FileMaker script to do the actual Insert Picture, after calling it from whatever AppleScript got your file. I would control the process from a FileMaker script, not an external AppleScript, unless that is required for other reasons. There are a few rough spots (1st time around).
1. An AppleScript Mac syntax file path looks like: Macintosh HD:Users:fej:Desktop:Picture.png
A FileMaker syntax path (for an image) looks like: imagemac:/Macintosh HD/Users/fej/Desktop/Picture.png
You need to use the FileMaker syntax file path when you Insert Picture. The only way Insert Picture will accept it is if you put it into a script Variable first.
The only way AppleScript can tell FileMaker what the Mac path is to set it (as text) into a text field (global likely). There are gotchas to do with that, passing data to/from AppleScript, but I'm assuming you know these, as you're using AppleScript. If not, let me know. Let's say you've had AppleScript put the Mac syntax full path (as text) into a "gMac_path" global field.
Set Variable [ $filepath; "imagemac:/" & Substitute ( gMac_path; ":"; "/" ) ]
Go to Field [ container field ] (must be on layout)
Insert Picture [ container field; $filepath ]
I am able to convert the Mac path to forward slashes in AppleScript by using the Posix Path.
What I don't understand is how you put the container field & variable name into the Insert Picture portion of the script.
In FileMaker 10, I go to File > Manage > Scripts then Edit my script.
I choose Insert Picture and move then Specify...
Trying to type in container field & variable name will not let me save. Can you manage a script another way??
Thanks for your help.
There are 2 "Specify" buttons, one for the Field, one for the Variable. You pick the field in the 1st specify, and type the variable's name ($path, no quotes) in the 2nd.
I do not have 2 "Specify" buttons. Using FileMaker Pro Advanced 10.0.v3 on Mancintosh. Also check FileMaker Pro 10 on another Mac & Windows machine, same thing.
I'm only seeing Script Step Options "Store only a reference" checkbox, "Specify source file" checkbox, and "Specify..." button (last two options open the same "Specify Picture File" dialog with an "Add File..." button to choose a file and a text area to type or display "File Path List". Anything I type in wants to have a file path syntax and will appear in the Insert Picture [ ] brackets in quotes.
Are you using version 11???
drop the field name out of the Insert Image step and just use the variable name. It worked for me
Set Variable[$path; "path"]
Go to Field[Table::Image]
I have tried this and it still will not work on my end. My variable in the Insert Picture [ ] step is in quotes. Doesn't this mean it will treat it as a string and not a variable. When I run it I get "The file "$PathToFile" could not be found and is required to complete this operation."
I'm thinking the quotes need to go for the variable to pass its contents correctly...
Yes its in quotes thats just FM saying this is what was specified.
If its failing then the problem is with the path string.
All I did was set the variable to "imagemac:/volume/folderpath/filename" which could be done in a calculation manner as well
You might want to throw the variable out in a dialog box to see if your computation isnt coming out right
Sorry, re: 2 "Specify" buttons. I was looking at an Insert File step, and didn't realize the older Insert Picture did not have the "specify" field button (it should :-).
But, yes, no quotes around variables. They are more like fields in that way, ie., a FileMaker object, not text: $path
And yes, you'd want to see your path. It is very easy to end up with a double slash, or missing one, or missing the "imagemac:/", etc.; easy to see.
The script step will put the quotes around it you don't when you manage scripts
Sorry if that wasn't clear.
Just type $variablename into the box rather than going to the add dialog
Alright I found my problem. Since my images were on a mounted server when I performed my Posix Path in AppleScript to make the path acceptable for FileMaker with the slashes, it was adding Volume to the front of the file path. Removing this solved the problem and I'm able to insert my pictures using AS and the do script. Cool..... Thanks for the help guys!!! This is just the beginning of my database project. I'm sure I'll be back for more advice...