为什么在 BBEdit 的 AppleScript 中使用替换会出现错误?

Why am I getting an error using replace in AppleScript for BBEdit?

我正在尝试为 BBEdit 制作一个 AppleScript,通过将每个小时替换为下一个小时,将所有内容按计划提前一小时。我以前用过 AppleScript 和 BBEdit 很多次,但这是我第一次同时使用它们,我不知道出了什么问题。这是我的脚本的前两行。

告诉应用程序“BBEdit” 将文本“12:”替换为文本“{#pl}:”

“{#pl}:”是一个占位符。我在没有“文本”关键字的情况下首先尝试了这个并得到了同样的错误。每当我 运行 我收到一条错误消息说“BBEdit 出错:文本“12:”不理解“替换”消息。”有什么问题,我该如何做我想做的事?谢谢。

您需要 replace 命令的目标,可以通过另一个 tell 语句或 searching in 参数。包括从哪里开始可能会有所帮助,例如:

tell application "BBEdit"
   tell front document
      replace "12:" using "{#pl}:" options {starting at top:true}
   end tell
end tell

-- or --

tell application "BBEdit" to replace "12:" using "{#pl}:" searching in front document options {starting at top:true}