title: getting an index of a selected item in a list apple script
body: <p>I'm trying to write an apple script with a large list and I want to prompt the user to select an item from the list and then the script should display an index of this item. Getting the script to prompt the user to select from list wasn't a problem, but I can't get an index of a selected list item.</p>
  <p>Here is the example code and a loop I tried so far</p>
  <pre><code>set cities to {&quot;New York&quot;, &quot;Portland&quot;, &quot;Los Angelles&quot;, &quot;San Francisco&quot;, &quot;Sacramento&quot;, &quot;Honolulu&quot;, &quot;Jefferson City&quot;, &quot;Olimpia&quot;}
  set city_chooser to choose from list cities
  set item_number to 0
  repeat with i from 1 to number of items in cities
      set item_number to item_number + 1
      if i = city_chooser then
          exit repeat
      end if
  end repeat
  display dialog item_number
  </code></pre>
  <p>It just gives me the number of items in the list.</p>