Reputation: 13
I'm trying to make a droplet script in Applescript using the code below.
I have a handler which runs a command line with the POSIX path of the selected file.
When I run the script everything works (my command line handler works fine). But, if I drop the file to my script, nothing happens.
I need some help, please
on run
set thePath to POSIX path of (choose file of type "img" default location (path to downloads folder from user domain))
doIt(thePath)
end run
on open myImageFile
tell application "Finder"
if (count of myImageFile) is greater than 1 then
display alert "A message" as critical
else if name extension of item 1 of myImageFile is not "img" then
display alert "A message" as critical
else
set thePath to POSIX path of item 1 of myImageFile
doIt(thePath)
end if
end tell
end open
Upvotes: 0
Views: 71
Reputation: 1409
Change the line: doIt(thePath)
in the open handler into: my doIt(thePath)
.
The reason for the error, is that you try to use your handler from within the scope of finder, and finder, doesn't reckognize it as something of its own. Therefore you must add my
in front of it, so the handler can be resolved.
Upvotes: 1