由于“使用脚本"而导致的行尾错误 [英] End of line error due to "use script"
问题描述
我有一个运行良好的苹果脚本,直到我在开始时添加use scriptAlert Utilities"
.然后它给出预期的行尾等但找到标识符.在set md5 处出错以执行 shell 脚本md5 -q" &引用形式的 myFile
突出显示 shell
.什么可能导致此错误?
I have apple script which is working perfectly fine, until I add use script "Alert Utilities"
at the start. Then it gives Expected end of line, etc. but found identifier. error at set md5 to do shell script "md5 -q " & quoted form of myFile
with shell
highlighted. What could possible be causing this error?
推荐答案
添加使用脚本添加
,代码将正常运行.从 AppleScript 2.3 (Mavericks) 开始,就有了新的 use
语句.它将告诉运行脚本所需的必要资源,例如 AppleScriptObjC 中的哪些应用程序(可选)、脚本库、可可框架,或者是否会使用脚本添加.为了在不使用 use
语句时向后兼容,默认情况下加载脚本添加.如果使用 use
语句,则默认情况下不会加载脚本添加项.
Add use scripting additions
and the code will run fine. Since AppleScript 2.3 (Mavericks) there is the new use
statement. It will tell the neccessary resources that are required to run the script like which applications (optional), script libraries, cocoa frameworks in AppleScriptObjC or if it will use scripting additions or not. For backward compatibility when the use
statement is not used, by default scripting addition are loaded. If the use
statement is used, the scripting additions are by default not loaded.
所以你的脚本看起来像:
So your script will look like:
use script "Alert Utilities"
use scripting additions
-- continue code
set md5 to do shell script "md5 -q " & quoted form of myFile
这篇关于由于“使用脚本"而导致的行尾错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!