我是Apple脚本的新手,我有一个简单的苹果脚本,在下面 -
display dialog "Enter Your User Name:" default answer ""
set theUser to the text returned of the result
现在,如果用户未输入任何内容并点击OK
,我会检查
if theUser = "" then
display dialog "User name is mandatory" buttons {"OK"} with title "Missing parameter" with icon "stop"
set theError to button returned of the result
if theError is "OK" then quit
end if
但是当检查Resource wasn't found.
条件时,它会弹出if
个错误。我尝试了theUser is in {"",value missing}
,theUser is missing value
等,但这些也无效。这有什么不对吗?
答案 0 :(得分:1)
停止不应该在引号中。我假设您希望脚本在发送“退出”命令时停止执行。您可以通过添加取消按钮参数来完成此操作。
display dialog "Enter Your User Name:" default answer ""
set theUser to the text returned of the result
if theUser = "" then
display dialog "User name is mandatory" buttons {"OK"} default button {"OK"} cancel button {"OK"} with title "Missing parameter" with icon stop
end if