Jump to content
Server Maintenance This Week. ×

Apple script not working in runtime


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

Recommended Posts

I'm a newbie to FM and need some help...

The following native Applescript (button opens FM container field named "document" containing a PDF file with Adobe Reader) works in FMProAdvanced 9.0v3 but not in runtime 9.0v3. How do I get this to work in both?

I think I need to somehow get the MacOSX v10.4.11 to associate Adobe Reader v7.1.0 in the runtime version of the program. When I finish entering the native Applescript code for the button, I am then asked to choose an application. I then select Adobe Reader.

The same problem occurs with another button that runs Adobe PhotoShop with JPEG images.

Thanks,

- Jansen

Error message: Object not found.

Unknown Error: -1728

Applescript code executed via Adobe Reader button with the above error messages...

tell application "FileMaker Pro"

set filePath to cell “document” of current record

set filePath to filePath as string

end tell

tell application "AdobeReader"

activate

open file filePath

end tell

Applescript code executed via Adobe PhotoShop button with the same error messages...

tell application "FileMaker Pro"

set filePath to cell “image” of current record

set filePath to filePath as string

end tell

tell application "Photoshop"

activate

open file filePath

end tell

Link to comment
Share on other sites

Probably it's because you are not application "FileMaker Pro", you are whatever the runtime application is. But, no matter, you do not need the line:

tell application "FileMaker Pro"

when you're running AppleScript within a Perform AppleScript step.

The application knows itself, it does not need that line, and it just causes problems. Try it without it, or just comment it out. Don't forget to also remove/comment out the end tell line. I usually just comment it out, because then you can remove the comments if you need to copy/paste it into Script Editor for testing (Script Editor needs those lines).

I think this will fix it. I don't remember for runtimes, but I think it would be much the same.

Edited by Guest
Link to comment
Share on other sites

Fenton is right here, but since the script not is embedded in the solution, run from either Photoshop or Adobe Reader is the thing you adress not filemaker anymore, it should the name chosen for the bound solution.

--sd

Link to comment
Share on other sites

I think the AppleScript is embedded in the solution:

native Applescript (button opens FM container field

I don't know what exactly he means by "native" here, unless he means it is in Perform AppleScript step (I assume). But "button" implies it's in the FileMaker file. Unless he's calling an external AppleScript applet. Which would be unnecessary, from what we see here.

Link to comment
Share on other sites

By native, I meant "native" Applescript as opposed to "calculated" Applescript code.

I also meant that I have a button that calls (hence the "via") a script which runs my Applescript code.

I need to learn how to ask FM questions better.

Thanks for your comments Søren.

Link to comment
Share on other sites

Yeah, that's what I thought you meant. But it's always best to use the actual FileMaker term Perform AppleScript, so we know you're not talking about an external AppleScript script file, which could do the same thing, but WOULD require the tell app "FileMaker Pro" line. It's often confusing talking about FileMaker and AppleScript, because of this flexibility.

Link to comment
Share on other sites

Well further examination have shown me that Acrobat Reader, have no facilitations like of the shown above), although I seem to remember having seen such with Photoshop - or is it an addition?

It's not that Fenton or I should dictate what nomenclature to use here, but we usually descripe scripts such like this, as "embedded" ... but similar could we sometimes be caught in embedding a static AS, independent of any calc'fields what so ever. Whether they actually are compiled or interpreted by the OS have at least I no ideas how to examine to get any facts established!

--sd

Billede_1.jpg

Link to comment
Share on other sites

Just got back from trying it with the modified code...

set filePath to cell “document” of current record

set filePath to filePath as string

tell application "AdobeReader"

activate

open file filePath

end tell

It works in FMProAdvanced 9.0v3 but produced the following error message in FMRuntime 9.0v3...

"Adobe Reader application launching is not available with this runtime version."

The following worked in both version for AdobePhotoshop v7.0.1. I'm not able to confirm that it works with later versions of AdobePhotoShop.

set filePath to cell “image” of current record

set filePath to filePath as string

tell application "AdobePhotoshop"

activate

open file filePath

end tell

Link to comment
Share on other sites

That's interresting because due to license issues have there been put a lock on:

http://www.filemaker.com/help/Script-Steps69.html

It does apparently rub of - But this must be easy to circumvent, save the AS as external applet called from:

http://www.filemaker.com/help/ScriptsRef-266.html

Which then plucks the parameters backwards from filemaker and use them, unless you know how to use Event Class and Event ID for the conveyance of the parameters?

--sd

Link to comment
Share on other sites

Thanks again.

I'm new to Applescript and don't understand what you are saying.

Are you saying that there is a work-around using Applescript where I must save to a temp PDF file using the "Save Records AS PDF" script step and then use the "Send Event" script step to run AdobeReader with the temp file as a parameter?

If so, how do I run it and how would the code look like?

- Jansen

Link to comment
Share on other sites

No what I'm saying is that a some of the exporting stuff, have been deliberately crippled when turned runtime. Acrobat is included in the off the shelf filemaker in the function I mention, where the license then are paid per copy of filemaker.

But Filemaker Inc. have absolutely no idea how many copies of a runtime you're likely distribute, so they can't pay Adobe any unmeasurable up front.

The way the use is restricted is interesting, because if you embed something asking Acrobat Reader to launch a document, is it apparently interpreted as trespassing - by the crippling measures instated when you bound your solution.

The way to circumvent this restriction, must be to make a applet in scripteditor (if it's your choice of AS editor) and then compile it. The application you make can reside in a container-field and be send to /temp if needed, and then called by a Send Event[ scriptstep from filemaker.

This applet should be compiled with the use of the bound solutions name in the "tell application XXX" clauses, which wouldn't be neither Filemaker Pro nor Filemaker Pro Advanced!

There's apparently no need to do the same with the Photoshop - and this is because there's no stepchild element's from photoshop inside the runtime.

Now you have however been hiding the purpose and context you would be needing these trickeries in ... so perhaps most of your desired task might instead easily could be served by:

http://www.apple.com/applescript/imageevents/index.html

Instead of expecting Acrobat Reader or Photoshops precense on the machinery which are likely exploit your runtime

--sd

Link to comment
Share on other sites

I was not aware of the restriction, that you can't even tell Adobe Reader to open a file. That seems overkill to me, but then a lot of what Adobe does seems that way to me.

I guess a big question for me is why you are not just letting the Finder open the file? That way whatever application is the default PDF reader on the user's computer will open the file. The default would be Preview.

Some people (like me) do not even have Adobe Reader on their computer (well, I have it in my Windows installation, but not on Mac). Preview works well enough for what I do. I also use Skim, if I want real AppleScript support.

Link to comment
Share on other sites

Hi,

Sounds like a better solution. How do you modify my Applescript to allow the Mac OSX finder to open the document with it's default application?

Here's my original Applescript...

set filePath to cell “document” of current record

set filePath to filePath as string

tell application "AdobeReader"

activate

open file filePath

end tell

- Jansen

Link to comment
Share on other sites

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