Populating a Dropdown from a text file

New to this so hope someone can help me.

I need to populate a combo box with the following information from a text file

12 MTV
15 Viva
18 Music
27 Discovery

and so on

When the user makes his selection and chooses say “15 Viva” I need a variable to be set to 15.

Simple enough I think.

Thanks in advance…

Andrew

If your text file is in the format

Then this should set you up:


set ChoiceList to paragraphs of (read (choose file))

set MyChoice to (choose from list ChoiceList default items item 2 of ChoiceList) as string
--Your variable
display dialog MyChoice

SC

How would I specify a certain place on my Macintosh HD instead of using choose file? Say at…

Macintosh HD:Users:username:Desktop:choiceList.txt

set ChoiceList to paragraphs of (read file (Macintosh HD:Users:username:Desktop:choiceList.txt))

set MyChoice to (choose from list ChoiceList default items item 2 of ChoiceList) as string
--Your variable 
display dialog MyChoice

SC