开发者

Handler call error in tell block in Applescript

开发者 https://www.devze.com 2022-12-27 20:38 出处:网络
Why a handler is not called within the tell block? Error is -1708 on stub() -- method is not called in tell block

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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消