End of line error due to “use script”

南笙酒味 提交于 2020-02-05 13:57:53

问题


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?


回答1:


Add use scripting additionsand 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



回答2:


Add use "scripting additions" statement. use statement automatically disables scripting addtions such as display dialog.

also,

set md5 to (do shell script "md5 -q " & quoted form of myFile with shell)


来源:https://stackoverflow.com/questions/29666090/end-of-line-error-due-to-use-script

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