Matthew F Posted September 17, 2004 Posted September 17, 2004 Does anyone know how to set the file name reference for an image container through a script or calculation? I can get the file path of an image that is stored as a reference through the function: GetAsText(ContainerName) but I'd like to change the path and automate the choice of image to be displayed. The obvious advantage of this is that it would allow FMPro to play nicely with iPhoto or other photo repositories without having to import images. Thanks!
Fenton Posted September 17, 2004 Posted September 17, 2004 You can display an image via calculation, with the relative file path. For example, if the image file is in a folder "Images," inside the folder containing the database file, the calculation would be: "image:Images/" & file name result "Container" (not Text, though you might want to make a temporary text one, just to see the path). If the Images folder is "up" one folder from the database: "image:./Images/" & file name If the image is on another volume: "image:/" & VolumeName & path to file Try it. It's a relative file path, not a Mac absolute file path. (P.S. also works with "file:", but obviously only displays the icon.)
carlschneider Posted October 3, 2004 Posted October 3, 2004 That is the solution I was looking for too and works great. Thanks! My only problem now is that when I publish my database via IWP my proportions become skewed. I have the "Maintain original proportions" box checked and it looks fine on my desktop. However, when viewed on the web the image fills the field box, no matter if it is a horizontal or vertical image and it does not maintain the original proportions. Does anyone have a solution for this?
Ballistic P Posted October 15, 2004 Posted October 15, 2004 Long time listener, first time caller... The above formula is working pretty good for me but I have and additional need that I hope someone can help me on. Below is the description of how we use the database, and the additional function I am hoping to have. USE: We are a 3D production house in the middle of developing a video and 1al of the artist open up the "Asset Manager Database" to see what shot number they have been assigned and then go open the corresponding storyboards image to see how the shot needs to be animated, lit, etc. (this waists a little time because each person needs to open up 2 different things to look at for a single shot) What I would like is to have the Shot ID and the Storyboard match within the database itself. NEED: How I have it broken down now is that each shot number was imported from an Excel file and is listed under a static Field, which changes from shot to shot as someone hits the next button (e.g. Page 1= Shot AA_001, Page 2= AA_002, Page 3= AA_002_B, etc). What everyone here has to do now is to open up a separate directory and locate the corresponding storyboards to see what needs to take place in their assigned shot. What I would like to do is to incorporate the shot matching image of each board within the database pages themselves. The above calculation works but I will manually have to put in all 300 formulas. Is there a way to pull the matching image which reflects the static shot number at the top of the page? (example: If I go to page 27 I see shot AB_011_G posted as the header, I would like to have Storyboard AB_011_G.jpg showing to the right so they can reference it, so on and so on with each shot and matching .jpg) Any help is greatly appreciated. Hopefully I have made sense here. Ballistic
transpower Posted October 15, 2004 Posted October 15, 2004 Fenton: I tried this on Windows XP and I keep getting "The file cannot be found:" (followed by the path). I use the absolute file path like: "Image:/" & file_ref where file_ref is a text field which contains the path (like d:acrobat 5.0docskerules.pdf). Is there some slight change of syntax for Windows?
Fenton Posted October 15, 2004 Posted October 15, 2004 Yes, they're slightly different. Insert an image in a Container field, as a reference. Use the calculation: GetAsText (Container field), result Text. See what it looks like. That's probably the most sure thing. There's also some examples right there in the File Reference dialog; not for "image:," but for general slashy things :-) Normally, on a Mac, you don't use that 1st slash after "image:" unless it's on another volume.
transpower Posted October 15, 2004 Posted October 15, 2004 No, that doesn't work. Just the name of the file is displayed. Here is the calculation (result = container) GetAsText (Calctest::file_name_for_container) where Calctest::file_name_for_container is the filename the user enters. I want the container field to display the object whose filename I type. If result = text, I get a regular notes field. I've also tried "winimage:/" as per the help in Scripts--but that doesn't work either.
Fenton Posted October 15, 2004 Posted October 15, 2004 I was just saying to use GetAsText (Container field) to SEE what the path looks like; NOT to show an image, or do anything else. It has to be a file/graphic inserted "as reference." Create a test field and try it. The result of the GetAsText calculation is TEXT. Because I'm positive that it's just some little tweak to the slashes is what you need. I believe all the FileMaker path slashes are forward, "/". But I'm on a Mac right now, so I can't test. These relative paths are more like web address paths than the operating system absolute paths. It is somewhat annoying that this is mention NOWHERE in the FileMaker Help. I couldn't find it anyway.
transpower Posted October 16, 2004 Posted October 16, 2004 OK, it does just show the path (no problem); but I'm trying to show the corresponding image (picture, PDF, whatever) automatically! None of my FileMaker books says anything about this situation. I tried both forward and reverse slashes--neither worked; I tried both the regular file name convention and the Universal Naming Convention (UNC)--neither worked; I've tried both absolute paths and relative paths--neither worked. I even put a test image in the same directory as the file--but FM still says "The file cannot be found." I've tried both auto-entered calculated container fields and regular calculated fields with result=container--neither worked. I've tried no quotes and quotes for the file name--neither worked. Maybe someone who's at the "Expert" skill level could help us here.
Fenton Posted October 16, 2004 Posted October 16, 2004 Yes, it's certainly one of the most underdocumented features I've seen. The whole reason of using GetAsText was so that you could see what the path looks like. On my computer either of the path values from GetAsText will produce the picture. Relative: image:abduction.jpg Absolute: imagemac:/Macintosh HD/Users/fej/Documents/FileMaker/My_FM/FM 7/Container Fields/abduction.jpg Relative will work on Windows. Absolute won't (obviously). It won't work if I move the whole folder (database and picture) either. Your picture, Inserted as a Reference only, the GetAsText, with Text result, will show the Windows paths. I'm not saying this is the way to do it on a user's machine. It's kind of backwards. But this is a way to see what the path should look like. Then you just put the above in a calculation, with result Container, and you get a picture. Maybe you should upload a empty example file. There's some simple misunderstanding here. ImageFromPath.zip
transpower Posted October 16, 2004 Posted October 16, 2004 I tried the reverse approach, but cannot get the file name to display in the corresponding text field. I can make the container field a button which runs a script which has the step Insert Object. If I click the field once I can select the object to insert; if I click it twice I can get the object to open. If I make the corresponding text field a calculated field using GetAsText(container_field) I just get a "?". I'm sure someone out there knows how to solve it. I can attach my experimental file (it's not a production or commercial file, just something I use to test for this forum). calctest2.fp7.zip
Fenton Posted October 16, 2004 Posted October 16, 2004 The problem is that you are using a Windows-specific "Insert Object", which is an OLE object (I imagine). Use one of the cross-platform steps, such as Insert Picture, etc..
transpower Posted October 16, 2004 Posted October 16, 2004 But I'm on Windows and I want to "Insert Object." I guess we'll have to wait for some Expert to chime in.
transpower Posted October 17, 2004 Posted October 17, 2004 I've now discovered a work-around that's close. Suppose my table is called "Calctest 2", suppose I have a container field called, aptly enough, "container", and suppose I have a text field called, naturally, "file_name_for_container." Then I can have a script, called "Get_Container", which has this one line: Insert Calculated Result [select ; Calctest2::container ; "imagewin:/" & Calctest2::file_name_for_container] Clicking a button on the layout performs the script and inserts the image. I have not been able to get EventScript (a plug-in) to work so as to avoid pressing the button after changing the text field. Also, the above method does not work for PDF's...but it's better than nothing. Note: the file_name_for_container must have a path with forward (not reverse) slashes.
cjaeger Posted October 18, 2004 Posted October 18, 2004 Why not set the container to a calculation if (not(isempty(Calctest2::file_name_for_container)),"imagewin:/" & Calctest2::file_name_for_container) instead of a script?... -- precede it with an if-statement for the platform .... Abs(get (System Platform) = 1 ;PathToMac_image_folder; PathToWin_image_folder -- check for any errors using apropriate status functions ... Get(Calculation error) .... -- use a "where is my image folder" script at opening: if (pattern count( Calctest2::container;"not found") > 0 .... [...do script...]
transpower Posted October 18, 2004 Posted October 18, 2004 That works fine--I swear I tried that before and it would not work! Oh, I know why: I had reverse slashes rather than forward slashes in the path.
transpower Posted October 19, 2004 Posted October 19, 2004 OK, but we're not done yet. Rather than inserting an image, suppose we want to Insert Object (like a PDF) into the container field. What would be the correct calculation function then?
Recommended Posts
This topic is 7409 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 accountSign in
Already have an account? Sign in here.
Sign In Now