Using libraries with embedded AppleScript

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Using libraries with embedded AppleScript Thu Dec 02, 2021 11:41 am • by crp1212
I am trying to get the 'Run AppleScript' action to work but I'm running into a number of problems.

First, the embedded editor refuses to compile any 'use' statement (e.g. 'use scripting additions' or 'use script "MyLibrary"'). It gives the error message 'Expected “end” but found “use”.'

Second (and presumably relatedly), I can't get it to run any AppleScript handler. For example, this:

`script "myLibrary"'s test()`

It works without a problem in every other app I've tried but not in Hazel. Any help would be appreciated!
crp1212
 
Posts: 2
Joined: Thu Dec 02, 2021 11:31 am

Re: Using libraries with embedded AppleScript Fri Dec 03, 2021 10:37 am • by Mr_Noodle
When using an embedded script, it is implicitly inside a handler so you can't do anything there that you can't in a handler. For that type of thing, you will need to use an external script. Also note that Hazel expects a specific handler. Please see the manual as it's explained there.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Using libraries with embedded AppleScript Fri Dec 03, 2021 4:33 pm • by crp1212
Mr_Noodle wrote:When using an embedded script, it is implicitly inside a handler so you can't do anything there that you can't in a handler. For that type of thing, you will need to use an external script. Also note that Hazel expects a specific handler. Please see the manual as it's explained there.


Okay thank you very much for the guidance. I was also having some difficulty running external scripts but I figured out a workaround for the internal method:

`do shell script "osascript -e 'test() of script \"myLibrary\"'"`
crp1212
 
Posts: 2
Joined: Thu Dec 02, 2021 11:31 am


Return to Support