AppleScript处理程序从Tell Finder块中调用时不起作用



学习与AppleScript中的处理程序一起工作,我遇到了问题。目前,我已经修剪了我的申请来打电话给处理程序,但目前我会遇到错误:

error "Script Editor returned error -1708" number -1708

当我编译时,我没有问题。当我尝试研究解决方案时,我找不到在应用程序查找器下这不起作用的原因。要记忆,我记得必须在应用程序中声明on run

代码:

on checkForRebels(tieFighter, starDestroyer)
    display dialog "dark enough" as text
end checkForRebels
on run
    tell application "Finder"
        set the starDestroyer to (choose folder with prompt "Please select the Destroyer")
        set tieFighter to items of starDestroyer
        checkForRebels(tieFighter, starDestroyer)
    end tell
end run

我尝试搜索

applescript项目传递给处理程序时丢弃错误

但我将苹果公司的错误返回,但没有回答我的问题。当我审查苹果关于处理程序的文档时,我看不到任何披露问题应该是什么。

当我将脚本修改为:

on checkForRebels(tieFighter, starDestroyer)
    display dialog "dark enough" as text
end checkForRebels
on run
    tell application "Finder"
        set the starDestroyer to (choose folder with prompt "Please select the Destroyer")
        set tieFighter to items of starDestroyer
    end tell
    checkForRebels(tieFighter, starDestroyer)
end run

它可以无问题地工作,但是为什么处理程序checkForRebels()在应用程序查找器的告诉块中不起作用?当我打电话给处理程序时,我必须始终在申请外工作以使其工作吗?

当您从告诉块或其他处理程序中调用处理程序时,您需要指定"我的",否则它在Finder dicitonary中寻找该命令。

my checkForRebels(tieFighter, starDestroyer)

来自Applescript语言指南在一个nell语句中调用处理程序:

要在tell语句中调用处理程序,您必须使用 我或我的保留词表明处理程序是 脚本,而不是应将命令发送到告诉目标的命令 语句。

最新更新