Re: "choose list" question....
Re: "choose list" question....
- Subject: Re: "choose list" question....
- From: Jake Pietrykowski <email@hidden>
- Date: Thu, 10 Feb 2005 11:15:43 -0600
Title: Re: "choose list" question....
Hi David,
> This is a problem I've had several times. I have a list composed of
> lists, e.g.:
>
> { {1, "H"}, {2, "He"}, {3, "Li"}...}
>
> I want to use 'choose list' to have someone select one or more entries.
>
> First problem, how to get the list of text strings -- {"H", "He", "Li"...}?
>
> Second problem, "choose list" returns the string (or strings)
> selected (e.g. {"Mg","Mn"} ).
>
> Is there a way to figure out what the other part of the tuple was
> without scanning the first list.
I don't know a way to search lists within lists without examining each list contents individually, and then creating a new list. Give this a try!
<snip>
set theList to {{1, "H"}, {2, "He"}, {3, "Li"}}
set textStringsList to {}
set theNewList to {}
-- Get the list of text strings
repeat with i from 1 to length of theList
set textStringsList to textStringsList & item 2 of item i of theList
end repeat
-- Choose text strings from list
set theChoices to choose from list textStringsList with multiple selections allowed
-- Create the new list to contain only selected
-- element numbers and text strings, as a list
repeat with i from 1 to length of theChoices
set listItem to item i of theChoices
repeat with n from 1 to length of theList
if item n of theList contains listItem then
set theNewList to theNewList & {item n of theList}
end if
end repeat
end repeat
-- Remove the double brackets for single item lists {{ }}
if (count of theNewList) is equal to 1 then set theNewList to item 1 of theNewList
theNewList
</snip>
Best Regards,
Jake
_______________________________________________
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