为什么在 AppleScript for BBEdit 中使用替换时出现错误? [英] Why am I getting an error using replace in AppleScript for BBEdit?

查看:24
本文介绍了为什么在 AppleScript for BBEdit 中使用替换时出现错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to make an AppleScript for BBEdit to move everything up one hour on a schedule by replacing each hour with the next hour. I've used AppleScript and BBEdit quite a bit before, but this is my first time using them together and I don't know what's going wrong. Here's the first two lines of my script.

告诉应用程序BBEdit"替换文本12:"使用文本{#pl}:"

tell application "BBEdit" replace text "12:" using text "{#pl}:"

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

"{#pl}:" is a placeholder. I've tried this first without the "text" keywords and got the same error. Whenever I run this I get an error message saying "BBEdit got an error: text "12:" doesn’t understand the "replace" message." What's the problem and how do I make this do what I want? Thanks.

推荐答案

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

You need a target for the replace command, either through another tell statement or the searching in parameter. It would probably help to also include where to start, for example:

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}

这篇关于为什么在 AppleScript for BBEdit 中使用替换时出现错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆