1

I'm trying to create a simple international store for iTunes.

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

When I click US, it doesn't do anything with iTunes. What am I doing wrong?

2 Answers 2

1

The problem is that the choose from list command is returning a list of the items selected from the list. You can do the following:

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

Alternatively, you could say if item 1 of country = "US".

Sign up to request clarification or add additional context in comments.

2 Comments

+1 for revealing that the "choose from list" result is a list. That's the reason the poster wasn't getting what he expected. As such, out of your 2 solutions I prefer to use... if (item 1 of country) = "US" then approach.
(item 1 of country) and country as text produce the same result.
0

Try

if country as text = "US" then

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.