Search code examples
listapplescript

Applescript (list choices)


I need som help with a small Applescript.

When i make my choice in the list. Safari always open test3. Maybe someone can help me?

The code

set choice to choose from list {"1", "2", "3"}

if choice is "1" then
        tell application "Safari" to open location "http://test1/"


else if choice is "2" then
        tell application "Safari" to open location "http://test2/"

else
        tell application "Safari" to open location "http://test3/"
end if

Solution

  • The result from a "choose from list" dialog is a list. Even if it only has 1 item in the list it's still a list. So you really want "item 1" from the list to get the actual result.

    To fix your code change your first line to this...

    set choice to item 1 of (choose from list {"1", "2", "3"})