2012-10-30 22 views
1

我正在嘗試爲iTunes創建一個簡單的國際商店。AppleScript - 當使用「從列表中選擇」時,變量命令不起作用

set country to (choose from list {"US", "CA", "UK"} with prompt "What country?") 

    if country = "US" then 
    tell application "iTunes" 
    activate 
    open location "itmss://itunes.apple.com/WebObjects/MZStore.woa/wa/switchToStoreFront?storeFrontId=143441" 
end tell 
end if 

當我點擊美國,它不會對iTunes做任何事情。我究竟做錯了什麼?

回答

0

嘗試

if country as text = "US" then 
1

的問題是,choose from list命令返回從列表中選擇的項目列表。你可以做到以下幾點:

set country to (choose from list {"US", "CA", "UK"} with prompt "What country?") 

if country = {"US"} then 
    tell application "iTunes" 
     activate 
     open location "itmss://itunes.apple.com/WebObjects/MZStore.woa/wa/switchToStoreFront?storeFrontId=143441" 
    end tell 
end if 

或者,你可以說if item 1 of country = "US"

+0

+1表示「從列表中選擇」結果是一個列表。這就是海報沒有得到他預期的原因。因此,在我的兩種解決方案中,我更願意使用......如果(國家的第1項)=「美國」,則接近。 – regulus6633

+0

(國家的第1項)和國家作爲文本產生相同的結果。 – adayzdone

相關問題