Re: Selecting From A List
Re: Selecting From A List
- Subject: Re: Selecting From A List
- From: Deivy Petrescu <email@hidden>
- Date: Sat, 28 Apr 2012 17:31:00 -0400
On Apr 28, 2012, at 14:47 , Jim Brandt <email@hidden> wrote:
> 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
If it suits you:
<script>
set l to {"String 1", "String 2", "String 3"}
set tr to choose from list l
run script "set r to {|String 1|:1, |String 2|:2, |String 3|:3}\n\nr's |" & contents of item 1 of tr & "|"
</scripts>
Deivy Petrescu
email@hidden
_______________________________________________
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