为什么不在tell块中调用处理程序? 错误是-1708
on stub() -- method is not called in tell block
end stub
tell application "Finder"
stub()
end tell
答案 0 :(得分:13)
在tell SOMETHING
块中,AppleScript在SOMETHING
内查找命令。在这种情况下,它正在stub
内寻找application "Finder"
命令;这显然不存在。要告诉AppleScript查找您定义的函数,请编写my stub()
; my
强制它查看当前脚本的正文而不是application "Finder"
。在这种情况下,这会给你:
on stub()
-- ...
end stub
-- ...
stub() -- Works fine
-- ...
tell application "Finder"
-- ...
my stub() -- With the `my`, works fine
-- ...
end tell