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

非 Y 不嫁゛ 提交于 2021-02-11 13:50:50

问题


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.

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

"{#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.


回答1:


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}


来源:https://stackoverflow.com/questions/62985341/why-am-i-getting-an-error-using-replace-in-applescript-for-bbedit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!