Re: Choose from list
Re: Choose from list
- Subject: Re: Choose from list
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 16 Oct 2005 08:29:16 -0700
- Thread-topic: Choose from list
On 10/16/05 7:44 AM, "Robert Poland" <email@hidden> wrote:
> I have this line in a script;
>
> set theChoice to (choose from list theList default items
> theDefaultList with prompt "Select Calendar")
>
> I know how to get the text returned, but I would like to get the
> number of the item chosen.
>
> Page 337 of Matt's book doesn't even address this situation.
>
> Where else can I go to find this answer?
Here's the right place. It's a good question. AppleScript does not provide a
built-in answer. There are probably some osaxen (Satimage?) that do it - in
Classic days Akua Sweets had one. I use a handler:
set theChoice to (choose from list theList default items
theDefaultList with prompt "Select Calendar") as Unicode text
if theChoice = "false" then error number -128 -- cancel
set listIndex to my CollectUniqueItemIndex(theList, theChoice)
to CollectUniqueItemIndex(theList, theItem) -- the Item can be string,
number, constant, app object or list
local aListMember
set theIndex to 0
repeat with i from 1 to (count theList)
set aListMember to item i of theList
if aListMember = theItem then
set theIndex to i
exit repeat
end if
end repeat
return theIndex
end CollectUniqueItemIndex
I use a version incorporating a "Serge" script object to go faster when the
list is large (100 items or more).
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden