• 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: Shane Stanley <email@hidden>
  • Date: Sun, 29 Apr 2012 12:17:13 +1000

On 29/04/2012, at 4:47 AM, Jim Brandt wrote:

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?

As others have said, there's no simple answer; because the selection can also be a list, you'll need to loop through both your selection list and the original list.

ASObjC Runner can save you one loop:

set ListOfSelections to {"String 1", "String 2", "String 3", "String 4", "String n"}
set r to choose from list ListOfSelections with prompt "Pick one or more:" with multiple selections allowed
if r is not false then set r to my getindexes(ListOfSelections, r)

on getindexes(ListOfSelections, r)
tell application id "au.com.myriad-com.ASObjC-Runner" -- ASObjC Runner.app
set theIndexes to {}
repeat with oneMatch in r
set theIndexes to theIndexes & (look in list ListOfSelections matching oneMatch)
end repeat
return theIndexes
end tell
end getindexes

The good news is that the next version of ASObjC Runner, due shortly, will make it simpler:

set ListOfSelections to {"String 1", "String 2", "String 3", "String 4", "String n"}
set r to choose from list ListOfSelections with prompt "Pick one or more:" with multiple selections allowed
if r is not false then
tell application "ASObjC Runner" to set r to (look in list ListOfSelections matching items r)
end if

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

References: 
 >Selecting From A List (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: Selecting From A List
  • Next by Date: FMPro/Applescript error -10011
  • Previous by thread: Re: Selecting From A List
  • Next by thread: Re: AppleScript-Users Digest, Vol 9, Issue 188
  • Index(es):
    • Date
    • Thread