There are a number of different ways. What exactly is this a list of? Files, File Names, Folder Names, Paths, Strings?
If these are files then it might be good to repeat through the list and get the path to each and use that since that would guarantee a unique ID.
If these are just strings then perhaps you could repeat through each item and turn each one into a record such as {name:“a”, value:1}, {name:“b”, value:1}, {name:“c”, value:1}, {name:“a” value:2} etc
then work through a list of the records:
set theList to {{name:"a", value:1}, {name:"b", value:1}, {name:"c", value:1}, {name:"a", value:2}}
value of item 4 of theList
You have to do something to make the items unique. This is one way to do it:
set the_list to {"a", "b", "a"}
set choose_list to {}
repeat with i from 1 to (count the_list)
set end of choose_list to (i as Unicode text) & ". " & item i of the_list
end repeat
set the_choice to (choose from list choose_list) as Unicode text
if the_choice = "false" then return
tell (a reference to my text item delimiters)
set {old_tid, contents} to {contents, ". "}
set {the_choice, contents} to {the_choice's text item 1, ", "}
set {the_list_as_string, contents} to {the_list as Unicode text, old_tid}
end tell
display dialog "You chose item " & the_choice & " of {" & the_list_as_string & "}." buttons {"OK"} default button 1 with icon 1 giving up after 5
set the_choice to the_choice as integer
return item the_choice of the_list
on chooseIndex from l
set d to text item delimiters
set text item delimiters to ""
set o to ASCII character 0
set s to {}
set r to {}
repeat with n from 1 to count l
set r's end to l's item n & s
set s's end to o
end repeat
set i to choose from list r
if i is false then error number -128
set text item delimiters to o
set n to count text items of i's item 1
set text item delimiters to d
n
end chooseIndex
chooseIndex from {"a", "b", "a", "b", "a", "b"}
--> [integer]