我知道這是草率的代碼,但在這裏它是:AppleScript的語法
display dialog ("Start Screensaver. Please type: matrix, coffee, waffles, star, water, or
fireworks.", default answer "")
if text returned of result = "matrix" then
set user_choice to "MatrixSaver"
else
if text returned of result = "coffee" then
set user_choice to "Coffee"
else
if text returned of result = "waffles" then
set user_choice to "Waffles"
else
if text returned of result = "star" then
set user_choice to "Hyperspace"
else
if text returned of result = "water" then
set user_choice to "LotsaWater"
else
if text returned of result = "fireworks" then
set user_choice to "Skyrocket"
else
(*do nothing*)
end if
end if
end if
end if
end if
end if
if (user_choice = null) then (*do nothing*)
else
tell application "System Events"
set ss to screen saver user_choice
start ss
end tell
end if
當我嘗試編譯我的代碼,「默認答案」被突出顯示,並說:「預期「) 「等,但找到了標識符。」
任何想法?謝謝。
答案的後半部分不正確 - AppleScript只有本地(函數)和全局範圍。 –
@ fireshadow25當我按照你所說的做時,'默認'的'默認答案'被突出顯示,並且程序說它期望有一個「,」任何想法? – CodeKid
@CodeKid是的。除非你正在評估一個表達式,否則父項並不是真正需要的。我建議從'display dialog'語句中刪除兩個圓括號。 – fireshadow52