如何使用“考虑案例”在 Applescript 中处理 Microsoft Word 时
以下 Applescript 代码无法编译;编译器突出显示“case”并说:“语法错误:预期的应用程序常量或考虑因素,但发现了属性”。我猜 case
在 tell 应用程序“Microsoft Word”
的上下文中具有特殊含义。我怎样才能很好地解决这个问题?
tell application "Microsoft Word"
set c to content of character 1 of selection as string
considering case
if (c is "a") then
set content of text object of selection to "A"
end if
end considering
end tell
The following Applescript code does not compile; the compiler highlights “case” and says: “Syntax Error: expected application constant or consideration but found property”. I guess case
has a special meaning in the context of tell application "Microsoft Word"
. How can I work around that nicely?
tell application "Microsoft Word"
set c to content of character 1 of selection as string
considering case
if (c is "a") then
set content of text object of selection to "A"
end if
end considering
end tell
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我要做的就是尝试将
considering
块移到外部,以便它包含其他所有内容。看来
case
是 Microsoft Word 的保留字,因此在tell
块内的不同上下文中使用该词只会让编译器感到困惑,因此会出现语法错误正在得到。What I would do is try moving the
considering
block to the outside so that it encompasses everything else.It appears that
case
is a reserved word for Microsoft Word, and so using that word in a different context while inside thetell
block just confuses the compiler, hence the syntax error you are getting.fireshadow52 是对的...
fireshadow52 is right ...