• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Selecting From A List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting From A List


  • Subject: Re: Selecting From A List
  • From: Thomas Fischer <email@hidden>
  • Date: Tue, 01 May 2012 18:43:46 +0200

Hi Jim,

I use the stupidest(?) method: just count the items:


on item2Num(theItem, theList)
repeat with i from 1 to the count of theList
if item i of theList = theItem then return i
end repeat
return 0
end item2Num

Unless the list is very long (longer than a list I would like to choose from) this is fast enough.

Best
Thomas


Am 28.04.2012 um 20:47 schrieb Jim Brandt:

I have a need to select multiple items from a list (sometimes lists of hundreds of items).

After getting the selection, I need the index into the list of each item selected.
Is there an easy way to do this?

An example:

set ListOfSelections to {"String 1", "String 2", "String 3", ..., "String n"}

set r to choose from list ListOfSelections with prompt "Pick one or more:" with multiple selections allowed

Assuming I select "String 2", "String 3" and "String n", r contains a list {"String 2", "String 3", "String n"}

I need to know that the first string of the selection is item 2 of the original list,
the second string of the selection is item 3 of the original list and the third
string of the selection is item n of the original list. Is there a way to return the
item number of the original list instead of the selections themselves, or do I
now need to search the original list to pick out the positions?

TIA,

Jim Brandt
Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users This email sent to email@hidden
  • Follow-Ups:
    • Re: Selecting From A List
      • From: Shane Stanley <email@hidden>
  • Prev by Date: [ANN] AppleScriptDoc 1.3.2
  • Next by Date: Re: Variable & Handler Names in Script Debugger
  • Previous by thread: Selecting From A List
  • Next by thread: Re: Selecting From A List
  • Index(es):
    • Date
    • Thread