• 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: AppleScript-Users Digest, Vol 9, Issue 188
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript-Users Digest, Vol 9, Issue 188


  • Subject: Re: AppleScript-Users Digest, Vol 9, Issue 188
  • From: Adam Bell <email@hidden>
  • Date: Sat, 28 Apr 2012 16:13:27 -0300

I don't have time to alter this to your specific need, but this is how I do it: First, number the list of choices then after the choices are made, parse out the number:

set theFolder to choose folder

set theMenu to {}

set n to 1


tell application "Finder"

set folderItems to (items of theFolder)

repeat with theItem in folderItems

set theMenu to theMenu & (my leadingZeros(n) & " - " & name of theItem)

set n to n + 1

end repeat

end tell


set theSelection to (characters 1 thru 3 of item 1 of (choose from list theMenu) as string) as integer

tell application "Finder"

set thePath to POSIX path of (item theSelection of folderItems as string)

end tell

display dialog "the path of your selected file is " & thePath


on leadingZeros(n)

if n > 99 then

return n as string

else if n > 9 then

return "0" & n

else

return "00" & n

end if

end leadingZeros



On Sat, Apr 28, 2012 at 4:00 PM, <email@hidden> wrote:
Send AppleScript-Users mailing list submissions to
       email@hidden

To subscribe or unsubscribe via the World Wide Web, visit
       https://lists.apple.com/mailman/listinfo/applescript-users
or, via email, send a message with subject or body 'help' to
       email@hidden

You can reach the person managing the list at
       email@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of AppleScript-Users digest..."


Today's Topics:

  1. Selecting From A List (Jim Brandt)


----------------------------------------------------------------------

Message: 1
Date: Sat, 28 Apr 2012 13:47:17 -0500
From: Jim Brandt <email@hidden>
To: email@hidden
Subject: Selecting From A List
Message-ID: <email@hidden">email@hidden>
Content-Type: text/plain; charset="utf-8"; Format="flowed";
       DelSp="yes"

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20120428/425e2dc2/attachment.html>

------------------------------

_______________________________________________
AppleScript-Users mailing list
email@hidden
https://lists.apple.com/mailman/listinfo/applescript-users

End of AppleScript-Users Digest, Vol 9, Issue 188
*************************************************

 _______________________________________________
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

  • Prev by Date: Selecting From A List
  • Next by Date: Re: Selecting From A List
  • Previous by thread: Re: Selecting From A List
  • Next by thread: re: Selecting From A List (Jim Brandt)
  • Index(es):
    • Date
    • Thread