I have a field called Picture1 which is a text field. It contains the name of a file, of jpg type, that I want to dispaly in Container1. How do I set this up in a script, or what is the best way to do this?
xigent wrote: I have 670 records with filenames of pictures in a path c:\HERBS\JPG and I wantto lookup into a container by reference these file names for each record dynamically ( and automatically ).
I have 670 records with filenames of pictures in a path c:\HERBS\JPG and I want
to lookup into a container by reference these file names for each record dynamically ( and automatically ).
The folder looks to be "JPG" located inside "HERBS" on the C: drive.
The filepath that you need is something like
To generate this as a calculation using the field Picture1 (containing the value "bunnies") located in the table MyTable
"imagewin:/C:/HERBS/JPG/" & MyTable::Picture1 & ".jpg"
Note that you can define the container as a Calculation field with the above calculation and returning a value of type Container. You wouldn't need to update the field with a script each time the field Picture1 changes.
You only have two ways of displaying the actual jpg in FM:
1) you show it in a web viewer just like you would in a browser, by creating a URL to it
2) you insert the actual file into a container. Either physically inserting or by reference.
I am using the following code in a script:
Set variable [$FILE_PATH; Value: Database::PictureTextName1 & ".jpg"]
Show Custom Dialog ["Debug"; $FILE_PATH]
Insert File [Reference; Display content; Never compress; Database::Container1; "$FILE_PATH"]
Filemaker Pro 16 Advanced won't let me remove the double quotes around "$FILE_PATH" in the Insert File statement. Otherwise I believe this code would do the job. Any helpful suggestions.
The quotes around $FILE_PATH in the Insert File script step are normal.
What looks wrong to me is your
The value of $FILE_PATH needs to be a FileMaker file path. That is, it needs to start with one of the following:
If the value in Database::PictureTextName1 is something like "bunnies" to refer to the file with the name "bunnies.jpg" located in the same folder as your database, then you would want to use
Set variable [$FILE_PATH; Value: "file:" & Database::PictureTextName1 & ".jpg"]
If "bunnies.jpg" is located in a folder called Images which is in the same folder as your database file, then you would use
Set variable [$FILE_PATH; Value: "file:Images/" & Database::PictureTextName1 & ".jpg"]
Thank-you for your suggestions.
I have tried your exact advice and several permutations to no avail.
Can you please continue to offer additional advice and suggestions.
I am very grateful for your help.
Connecting a value in a field "bunnies" with a file "bunnies.jpg" located somewhere on your computer requires you to program in precisely where that file is located on your computer.
The examples I provided require you to customize them to your specific situation.
In order to provide further advice, we would need to know exactly where the jpg file is located relative to your FileMaker database file and what value is in the text field that references this jpg file.
all of the "insert" scripts will fail if the specified target field is not present on the current layout.
You you might usee insert file without any file or $path specified. Then a dialog opens where the user selects the file to insert. You might also do this as a test where you select "by reference", then use getastext ( container field ) to examine the text that is inserted. The last "paragraph" shown will be the specific file path to the inserted file. You can compare that to what you are assigning to a variable to see what differs from the path that you have attempted to use.
And since you are inserting an image file, you might use:
go to field [ table::containerfield]
instead of insert file
Without a filepath a dialog box DOES appear. But this is NOT what I want.
The error statement says the correct filename.jpg but it is as if it cannot find the correct directory. EXCEPT,
after the error statement it plants me in the right directory with a dialog box to locate the file manually.
I know this sound contradictory but this is what is happening.
I also tried the Insert Picture, it did not fix the overall problem, but I think I will stick with it since it is more
Please stick with me, with more suggestions.
Thank you for all your help.
xigent wrote: filenames of pictures in a path c:\HERBS\JPG
filenames of pictures in a path c:\HERBS\JPG
The reference for the 'insert picture' script step should look something line this:
filewin:/c:/herbs/jpg/<the actual file name here>
So as long as you transform the path text to that kind of syntax that FM expects then it should work.
You haven't shown us any code yet that shows how you take that windows-style path and how you change it to the filemaker-syntax for a path and how you do the actual insert by reference. Start there. Show us what you have.
Set Variable [$FILE_PATH; Value: "filewin:/c:/herbs/jpg/" & Herbs::Picture2 & ".jpg"]
Show Custom Dialog ["Debug";$FILE_PATH]
Insert Picture [Reference; "$FILE_PATH"]
The Dialog and the Error message both report the correct filename.jpg
There is some gross over-site. I am clueless. Could some global variable not be set correctly?
I changed it to imagewin from filewin and instantly it worked.
And bless you.
Retrieving data ...