Run AppleScript Embedded Error - expected end but found on

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

Moderator: Mr_Noodle

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)
united
 
Posts: 62
Joined: Wed Mar 14, 2012 3:48 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
united
 
Posts: 62
Joined: Wed Mar 14, 2012 3:48 pm

You need to use an external script if you want to use handlers.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support