kmoreau893 Posted June 30, 2005 Posted June 30, 2005 Hello. I've been scouring these forums and everywhere trying to do something that I believe is very simple, and yet I can't seem to do it. I have calculated some file names of image files. I have several fields that use those calculated file names and then put them into container fields. Basically this a database to show a main view of an item, plus alternate views, so the image file names are calculated as follows "<productname>.jpg", "<productname>_reverseangle.jpg", "<productname>_top.jpg" and so on. In some cases I don't have pictures for some of the variations, and so filemaker will put a message into the image container field: "The File Cannot Be Found" <imagefile name>. I know how to get the path to the file, I know how to calculate the absolute path to the file, if I need it. All I need is a function in a calculation field that goes something like this: if (filevalidate (imagefile name) = TRUE; "THE FILE EXISTS";"THE FILE DOESN'T EXIST")) Then based on whether I know if the file exists or not, I can include it (if it exists) or not (if it doesn't exist) in other calculated fields. By the way, "filevalidate" is my fictional function, it doesn't exist in Filemaker. I appreciate any advice. Thank you very much. -Keith
Wim Decorte Posted June 30, 2005 Posted June 30, 2005 No such think native to FileMaker. You would need to use a File plugin to do this in a calc. If you don't want to use plugins, use Applescript in a FM script to check if the file exists. The user will have to click a button to make the check happen though.
kmoreau893 Posted June 30, 2005 Author Posted June 30, 2005 Isn't there just some way, maybe using applescript within a calculation field (I don't even know if this is possible, been trying to find out) to just use some applescript code like "tell application "Finder" if the file "myfile.jpg" exists then set this field to TRUE else set this field to FALSE end if end tell Problem is I just can't figure out how to put Applescript within a field and then have it's output be the value of the field, that is really all I want to do...
Fenton Posted June 30, 2005 Posted June 30, 2005 [Attachment requires Troi File plug-in. I didn't attach a file for the AppleScript, as it's simpler to explain, just the code below.] You cannot get a "live" calculation with AppleScript. It must run a script. Below is the Perform AppleScript code for the step, which can be in a FileMaker Loop, for all records. It is similar to your code above, with the added conversion of the container field to a string value, which produces the path to the file. You should be on a layout with the container and the fields (read on). You will need a field named "theImage" (or change to your container field), and a text field named "ExistsAS", to put the test result in. In the below, an empty result is good. set theFile to "" tell current record of current layout of window 1 try set theFile to (get data cell "theImage") as string end try tell application "Finder" exists file theFile copy result to existTest end tell if existTest is false then set cell "ExistsAS" to "missing" else set cell "ExistsAS" to "" end if end tell As Wim suggested, there is an alternative method using the Troi File plug-in, which is cross-platform, and can actually calculate whether the file is there "live." It is an Unstored calculation. Troi_ImagePath.zip
kmoreau893 Posted June 30, 2005 Author Posted June 30, 2005 Thanks very much for the help. I did download the Troi plugin and it worked well. I have 30 days to decide to buy it it may be worth it for some of the 'live' versatility. Again, thanks to all who answered, you are great asset to these forums. -Keith
Recommended Posts
This topic is 7433 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