2017-02-12 62 views
1

我一直在试图构建一个脚本,通过显示对话框为您提供3种不同操作的选项,但是当我测试它们时只有第一个选项有效。有没有解决方法,因为这是我的程序的中心点。任何帮助表示感谢,并提前致谢!3个结果显示对话框?

set myQuery to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"} 
if the button returned of myQuery is "choice 1" then do script 
if the button returned of myQuery is "choice 2" then do script 
if the button returned of myQuery is "choice 3" then do script 

在这种情况下,只有选择一个脚本工作,其他两个失败。

回答

0

你在正确的轨道上。这应该为你

set myQuery to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"} 
if button returned of myQuery is "choice 1" then 
    say "you selected choice one" --replace this line with what ever you want 
end if 
if button returned of myQuery is "choice 2" then 
    say "you selected choice two" --replace this line with what ever you want 
end if 
if button returned of myQuery is "choice 3" then 
    say "you selected choice three" --replace this line with what ever you want 
end if 
+0

感谢您的回复。这是anoying意识到我是如此接近,但现在我有答案。再次感谢你的帮助! :) – user7439349

+0

相信我我明白了无奈。我是AppleScript的新手,我能想出的唯一解决方案是阅读阅读和练习练习。尽管......整个过程很有趣。 – wch1zpink

0

工作有很多冗余的代码和三个独立if条款效率不高。

set {button returned:myQuery} to display dialog "selection?" buttons {"choice 1", "choice 2", "choice 3"} 
if myQuery is "choice 1" then 
    say "choice one" 
else if myQuery is "choice 2" then 
    say "choice two" 
else 
    say "choice three" 
end if 
+0

感谢您的提醒。我仍在学习,但我很感激你指出。 – wch1zpink