Jump to content

Applescript to Open a File


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

Recommended Posts

  • Newbies

I have recently switched from Windows to Mac, and from Access to Filemaker. In one of my databases I had a hyperlink field which stored filepaths to .jpg and .pdf files, and served to open them. Nevertheless, this field has been imported into FileMaker as a text field, so I would need an AppleScript to open the file indicated in the said field.

At the same time, I will be sharing my database with some Access users, so I would also like to have an AppleScript which helps me to easily store filepaths into a text field.

I am aware that this question may have been posted before, but I have been unable to find it.

Thank you for your help.

Link to comment
Share on other sites

Well, AppleScript can do all this. But I think just plain FileMaker could also. A container field in FileMaker holds the file reference of a file/picture inserted into it [x] As a reference. You can see this by using a calculation GetAsText ( container field ). It is a FileMaker syntax path; which you can see in practically any dialog to do with external files (Insert, Import, Export, etc.).

What is not as widely known is that if you create a calculation, with its result the above path, and the result type of the calculation Container, then FileMaker will show the file/picture in the container field. When you think about it it makes sense; it's just the reverse of the normal "insert a file as reference." In this case you're telling FileMaker where the file is with a calculation; FileMaker is happy either way.

You need to add a prefix to the file if you want it to work on either platform. Say you have a picture, "Donuts.jpg" on your Desktop.

Let (

prefix = Case ( Abs ( Get (SystemPlatform)) = 1; "imagemac:"; "imagewin:");

prefix & Get (DesktopPath) & "Donuts.jpg"

)

Remember, the calculation result is Container.

The above will "show" the picture. If you want something that will open the picture (as a file), then you just need another calculation:

Let (

prefix = Case ( Abs ( Get (SystemPlatform)) = 1; "filemac:"; "filewin:");

prefix & Get (DesktopPath) & "Donuts.jpg"

)

It will show as an icon. You can either double-click it to open, or you can script a

Go To Field [ calculated container; select/perform ]

Something like that. I wrote the above on the fly; hopefully it is all correct; but it does work (if it is :-)

Edited by Guest
forgot the ) on the Case
Link to comment
Share on other sites

This topic is 5566 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.