你有三個if
語句,但你只end
其中之一。
你可能想在這裏什麼是else if
:
display dialog "Open Which Application" buttons {"Chrome", "AppleScript", "Textedit"}
set the button_pressed to the button returned of the result
if the button_pressed is "Chrome" then
open application "Google Chrome" -- action for 1st button goes here
else if the button_pressed is "Applescript" then
open application "AppleScript Editor" -- action for 2nd button goes here
else if the button_pressed is "Textedit" then
open application "TextEdit" -- action for 3rd button goes here
end if
(另外,你真的應該會使用end if
,不只是end
,但AppleScript的編輯器將修復你)
或者,你可以每個end
:
display dialog "Open Which Application" buttons {"Chrome", "AppleScript", "Textedit"}
set the button_pressed to the button returned of the result
if the button_pressed is "Chrome" then
open application "Google Chrome" -- action for 1st button goes here
end if
if the button_pressed is "Applescript" then
open application "AppleScript Editor" -- action for 2nd button goes here
end if
if the button_pressed is "Textedit" then
open application "TextEdit" -- action for 3rd button goes here
end if
然而,案件顯然是米非常獨特,所以沒有理由不使用else if
。
如果有幫助,通過一種類型在一個線路,看到的AppleScript編輯器是如何縮進他們:
display dialog "Open Which Application" buttons {"Chrome", "AppleScript", "Textedit"}
set the button_pressed to the button returned of the result
if the button_pressed is "Chrome" then
Open application "Google Chrome"-- action for 1st button goes here
if the button_pressed is "Applescript" then
Open application "Applescript Editor"-- action for 2nd button goes here
if the button_pressed is "Textedit" then
Open application "Textedit"-- action for 3rd button goes here
end
這應該很明顯出了什麼問題。