Jump to content

Filemaker Script to start an Applescript -- Failing


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

Recommended Posts

I have a simple Applescript that works in Script Editor

tell application "Keyboard Maestro Engine" 
do script "Search the Web" 
end tell

I add this same script (with escape chars) to my RESOURCES::A_SCRIPT field inside FM.

The RESOURCES table is not connected to the other tables in the graph.

"tell application \"Keyboard Maestro Engine\" 
do script \"Search the Web\" 
end tell"

I've tried this with this field being defined as a Global Storage Field or not.  Similar problems with both.

I have an FM Script called EXECUTE:

Perform Applescript (RESOURCES::A_SCRIPT)

When I run this FM Script I get an error message:

"Error: -2741" / "Expected EOL but found Command Name"

I've have tried rebooting my Mac.

Any ideas?

 

 

Link to comment
Share on other sites

If you're using a text field to hold your ApppleScript, then you shouldn't need to escape anything. Just copy-paste the script as is from Script Editor into the field. Do not add quotes, either.

 

Edited by comment
Link to comment
Share on other sites

Doesn't work.

I just copied the exact same (working) script from Script Editor into the FM Global Storage Text Field (no escape chars or double quotes).

Not accepted.  "Specified Field not found" when "Tell Application" is highlighted.

Edited by fm8443
Link to comment
Share on other sites

OK I've added this to the FM Script (Native Applescript panel):

tell application "Keyboard Maestro Engine" 
do script "Search the Web" 
end tell

It now works.

But how do I remove this code into a FM RESOURCES::A_SCRIPT field and then have it work similarly?

(I want to do this to build up to a more complex Applescript with parameters from FM.)

 

I've turned RESOURCES::A_SCRIPT field into a Text field and tried pasting the text of the Applescript into the DATA panel (or the CALC panel) of the Auto-Enter screen.  

tell application "Keyboard Maestro Engine" 
do script "Search the Web" 
end tell

I then reference this from the FM Script.  Still get the "Error: -2741"

Link to comment
Share on other sites

1 minute ago, fm8443 said:

(I want to do this to build up to a more complex Applescript with parameters from FM.)

 

An example would be useful.  In general, you have two choices:

1. Paste the AppleScript into the global field, then select the Calculated AppleScript option and enter a calculation that modifies the text in the global text field to what you want;

or:

2. Do the entire calculation within the Perform AppleScript step; this is the only option that requires you to escape the AppleScript - and the escaped version would look like this:

"tell application \"Keyboard Maestro Engine\" ¶do script \"Search the Web\" ¶end tell "

Of course, this is just the beginning, before you insert the parameters.

 

Link to comment
Share on other sites

7 minutes ago, comment said:

1. Paste the AppleScript into the global field, then select the Calculated AppleScript option and enter a calculation that modifies the text in the global text field to what you want;

Doesn't work for me.  Get error as above.

Do you men that I should paste the text of the Applescript into the DATA panel of the Auto-Enter screen of my RESOURCES::A_SCRIPT ?

tell application "Keyboard Maestro Engine" 
do script "Search the Web" 
end tell

And then reference this from my FM Script as this?

Perform Applescript (RESOURCES::A_SCRIPT)

I still get the "Error: -2741"


 

 
Link to comment
Share on other sites

11 minutes ago, fm8443 said:

Do you men that I should paste the text of the Applescript into the DATA panel of the Auto-Enter screen of my RESOURCES::A_SCRIPT ?

No. You should paste it into the field itself. Place the field onto a layout, enter Browse mode, click into the field and paste. Do not specify any auto-enter options for the field.

 

Edited by comment
Link to comment
Share on other sites

16 minutes ago, comment said:

No. You should paste it into the field itself. Place the field onto a layout, enter Browse mode, click into the field and paste.

OK done this on a new global text field.  Created clean new FM script as well.

Getting error -2741 "Expected EOL but found command name"

Also tried your #2 (escape chars etc) and I get no error message/no results!

Link to comment
Share on other sites

Thanks for the file.  It works as expected.  It also works when I copy in my Applescript.  

The weird thing is that 12 hours later MY script now works with no error message as I repeatedly got last night.  I made no changes to it at all!

Didn't reboot Mac or restart FM or KM or Safari.

My setup looks exactly the same as yours except I run the FM Script from the FM menu (not from a button).  Thanks again.

Link to comment
Share on other sites

14 minutes ago, fm8443 said:

The weird thing is that 12 hours later MY script now works with no error message as I repeatedly got last night.  I made no changes to it at all!

Maybe you have the first computer ever with the caprice feature...

Note that once you have finalized your AppleScript, you should move it from the global field and make it a self-contained calculation within the Perform AppleScroipt[] script step. Otherwise you will lose it if you clone your file.

Link to comment
Share on other sites

I had Googled 'Caprice feature' to try to understand your reference.  All I found was for a Chevy Caprice ( car ) and this:

http://www.washingtonpost.com/wp-dyn/content/article/2006/06/04/AR2006060400806.html

Clint Dempsey tries different things and some things work so I thought that might be your reference.  :-)

Link to comment
Share on other sites

Hmm ... they have "Caprice Is a Feature Of Dempsey's Game" as the headline -  but the word caprice is nowhere in the text, so it's hard to tell what they mean.

I meant simply that the computer could be acting "weird" because it's capricious. Which is just another way of suggesting that PIBKAC.

Link to comment
Share on other sites

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