0

我是苹果脚本的新手,我有一个简单的苹果脚本,它在下面 -

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但这些也不起作用。这里有什么问题?

4

1 回答 1

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
于 2012-08-29T17:10:43.210 回答