Jump to content
Server Maintenance This Week. ×

import picture using calculation?


This topic is 7255 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I would like to import pictures or/and check if they exist by using a calculation.

I know the name of the picture and the path but insert picture function does not work as i would like to.

For example, i have a file which contains information about "apple" and the picturefile is "apple.jpg" which resides in "apples" folder, then we have "lemon" etc. Is there a way to write a script which imports apple.jpg from apples folder and lemon.jpg from lemons folder etc?

I know, i can write an applescript for checking if picture file exists and write the result into FMP field but don't want to if there is a way using only FileMaker.

Thanks

Link to comment
Share on other sites

Check out the Import, Folder dialog. It's the same as any other Import dialog, which means it has the Update Matching Records option, where you click on the "key" to match with (turning it into <=>).

If you had a calculated key in FileMaker to match the Filepath (one of the fixed fields to import pictures or files), then you should be able to do what you want.

There is an "Include enclosed folders" checkbox at the 1st level of the dialog, which you'd want to leave on.

Your entire folder structure must be in a known location, relative to the database, hopefully within its folder. Then you can use the Get(Filepath) function to get your current location, and parse and add to get the filepath to the file.

If your current folder is field "myFolder", the calculation would look (something) like:

myFolder & folderName & "/" & filename

Actually, there's more. A "gotcha," to do with this silly "file:/" business. Get(Filepath) returns "file:/" now (7.0v2). But the darn Import Folder still expects "file://"! I wonder if this will be changed down the road? For now though:

Substitute (

Left ( Get(FilePath);

Position (

Get ( FilePath ) ; "/" ; 1 ;

PatternCount( Get ( FilePath ); "/" )

) );

"file:/"; "file://")

&

"images/" & PictureName

This seems to work for matching records. I just wrote "images/", but you'd use a field with the folder name. So the above is not entirely tested, but I think it'll work.

Link to comment
Share on other sites

If you are wanting to write a calculation based on values in a field to determine the path of the image ( I think that is what you mean ) You have to use the Troi plug in there are some extended functions that enable you to do this. Also you can log the error code in a field during the import, then this will tell you wether or not the image was found.

You can define a calculation field call "Image_Path" , a "folder" field, "image_name" field:

russell up something like this:

"file://osx/users/....../"&folder&"/"&image_name

I have use this for that exact reason and work a treat

You can get a demo which lasts 45 mins. from http://www.troi.com

There are examples included, you can tinker with these to acheive what you want.

hope this helps,

eric

Link to comment
Share on other sites

This topic is 7255 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.