Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handler call error in tell block in Applescript

Tags:

applescript

Why a handler is not called within the tell block? Error is -1708

on stub() -- method is not called in tell block
end stub

tell application "Finder"
    stub()
end tell
like image 921
Dmitry Dyachkov Avatar asked Apr 18 '10 20:04

Dmitry Dyachkov


1 Answers

Within a tell SOMETHING block, AppleScript looks up commands within SOMETHING. In this case, it's looking for a stub command within application "Finder"; this obviously doesn't exist. To tell AppleScript to look up the function you've defined, you write my stub(); the my forces it to look in the body of the current script rather than in application "Finder". In this case, this gives you:

on stub()
    -- ...
end stub

-- ...
stub() -- Works fine
-- ...

tell application "Finder"
    -- ...
    my stub() -- With the `my`, works fine
    -- ...
end tell
like image 83
Antal Spector-Zabusky Avatar answered Nov 10 '22 09:11

Antal Spector-Zabusky