Page 1 of 1

Run AppleScript Embedded Error - expected end but found on

PostPosted: Thu Feb 24, 2022 11:33 am
by united
I'm using a hazel rule to do the following. Run AppleScript with embedded script. I have his function that I call in various areas of the script.

when compiling I get "expected end but found on" error. If I don't use functions then it works. Are functions not supported in this interface in hazel or is there another way to declare these functions so that it works?

Code: Select all
on hideApp(appName)
   tell application "System Events"
      set visible of application process appName to false
   end tell
end hideApp

hideApp(appName)

Re: Run AppleScript Embedded Error - expected end but found

PostPosted: Fri Feb 25, 2022 10:20 am
by Mr_Noodle
You can't use handlers in embedded scripts because the script itself is in a handler. Looking at your script, it seems the handler is unnecessary so just grab the part inside the handler and use that. You'll need to change the variable names as well as appName is not set to anything. I'm not sure if you want that to be set to the file that matched the rule or something else.

Re: Run AppleScript Embedded Error - expected end but found

PostPosted: Mon Feb 28, 2022 4:05 pm
by united
Mr_Noodle wrote:You can't use handlers in embedded scripts because the script itself is in a handler. Looking at your script, it seems the handler is unnecessary so just grab the part inside the handler and use that. You'll need to change the variable names as well as appName is not set to anything. I'm not sure if you want that to be set to the file that matched the rule or something else.


This was more of a snippet to illustrate the issue.

Seems like in AppleScript you can call an handler within another handler. Is there any way where you can use handler with Hazel? https://stackoverflow.com/questions/411 ... nder-block.

"You'll need to change the variable names as well as appName is not set to anything." It has been just not in the code snippet provided.

I'm attempting to use a code that works in script editor to work with Hazel. Trying to see how to approach that.

Re: Run AppleScript Embedded Error - expected end but found

PostPosted: Tue Mar 01, 2022 9:57 am
by Mr_Noodle
You need to use an external script if you want to use handlers.