Re: "choose from list"
Re: "choose from list"
- Subject: Re: "choose from list"
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 14 Jul 2002 20:36:24 -0700
On 7/14/02 7:08 PM, "cricket" <email@hidden> wrote:
>
On Sunday, July 14, 2002, at 06:43 PM, Dave DeLong wrote:
>
>
> I have a problem (this sounds kinda stupid) with the "choose from
>
> list" option of AppleScript. If I have a script:
>
>
>
> choose from list {myList} with prompt myPrompt
>
> set myChoice to the result
>
>
The return value from 'choose from list' will be a list, so your check
>
for whether myChoice is "Books" will always fail. If "Books" is the
>
only chosen item from myList, myChoice will be {"Books"}
>
>
So, what you need for the second part is something more like:
>
>
if myChoice contains "Books" then
>
choose from list {myList2} with prompt myPrompt2
>
end if
>
>
> if myChoice is "Books" then --for example
>
> choose from list {myList2} with prompt myPrompt2
>
> end if
>
>
>
> the second choose from list will not work. Help?
>
>
- cricket
But since that would give a positive even where multiple selection is
allowed, it's better to change the first part instead.
Furthermore, it's still going to fail. There are two more errors.
If myList is indeed a list, it will be something like
set myList to {"Books", "Basketballs", "Violins"}
It will _already_ be in list brackets. So
choose from list {myList}
will actually be
choose from list {{"Books", "Basketballs", "Violins"}}
That will give the inevitable error "Can't make some data into the expected
type."
Same thing in the 'second choose from list {myList2}' with your suggested
solution. Get rid of those second set of list brackets!
So what he really wants is:
choose from list myList with prompt myPrompt
set myChoice to the result as string -- or 'item 1 of theResult'
if myChoice is "Books" then --for example
choose from list myList2 with prompt myPrompt2
set myChoice to the result as string
end if
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.