我可以定义一个可以与我的脚本一起使用的全局处理程序吗?

Can i define a global handler that I can use with my scripts?

我编写了很多 AppleScript,并使用库脚本组织了我的代码。有没有一种简单的方法来定义我可以从我的脚本中调用的通用处理程序?

例如,我创建了一个带有处理程序的库:

脚本Libraries/logger.scpt

to info(message)
  log(message)
end info

然后在我的客户端脚本上,我会做:

set logger to script "logger"
logger's info("Hello world")

是否可能,我该怎么做才能简单地将调用写为:

info("Greetings")

我想省略目标,直接从客户端脚本调用处理程序。

您将需要使用术语实现 AppleScript 库 - 即向库脚本添加字典。

此站点上有大量信息http://macosxautomation.com and specifically on this and subsequent pages https://macosxautomation.com/mavericks/libraries/terminology.html