2017-02-12 85 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