Re: 'choose from list' question
Re: 'choose from list' question
- Subject: Re: 'choose from list' question
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 12 Apr 2004 07:17:57 -0700
In the first case you're not taking a list since the command has not yet
been resolved to a list. Using the explicit 'get' or setting a variable to
the (result of) the command forces the command to execute and resolve to a
list of strings (unicode text, now) which the 'choose from list' command
needs.
Unfortunately, this is not uncommon. It's not just the Finder which does
this, although applications are very inconsistent about this. The new Apple
apps are among the worst offenders but there are many others which
occasionally have this unfortunate implemntation. (It's hard to know whether
to call it a bug or not, but it certainly seems to be aviodable by an
application's developers if they try harder.) Using an application command,
which must be resolved first, as the object of another command (whether
belonging to the application itself or to a scripting addition like 'choose
from list') can be unreliable. Sometimes it works and sometimes it doesn't.
It depends - consistently at least - on the commands in question. When it
doesn't, use the explicit 'get' in a single line, or a variable with two
lines.
--
Paul Berkowitz
>
From: Hanaan Rosenthal <email@hidden>
>
Organization: Custom Flow Solutions
>
Reply-To: <email@hidden>
>
Date: Mon, 12 Apr 2004 8:27:04 -0400
>
To: Brennan <email@hidden>, applescript-users
>
<email@hidden>
>
Subject: Re: 'choose from list' question
>
>
Hi Brennon,
>
>
In a perfect AppleScript world, the first script should work as well.
>
The issue here is that you're taking a list that the Finder created and pass
>
it
>
directly to the scripting addition command: choose from list.
>
>
Try this instead:
>
tell application "Finder"
>
choose from list (get name of items of window 1)
>
end tell
>
>
The get command forces the list to be parsed by AppleScript before moving
>
on to the scripting addition, therefore making it a generic list that the sa
>
can
>
chew on.
>
>
I bet someone else would have a deeper technical explanation as to the
>
nature of the two lists.
>
>
Hanaan
>
>
>
>
>
>
> I'm interested to discover that this fails with error -1700
>
>
>
> tell application "Finder"
>
> choose from list (name of items of window 1)
>
> end tell
>
>
>
> whereas this works fine
>
>
>
> tell application "Finder"
>
> set frontmostWindowItemNames to (name of items of window 1)
>
> choose from list frontmostWindowItemNames
>
> end tell
>
>
>
> ..and so does this
>
>
>
> tell application "Finder"
>
> choose from list ((name of items of window 1) as list)
>
> end tell
>
>
>
> I understand that an expression like (name of items of window 1) is not
>
> really a list, in fact, 'class of' returns {property, property,
>
> property...etc.}
>
>
>
> Given that this is not really a list, what is the correct name? I would
>
> call it a 'group of elements', but that seems vague.
>
>
>
> If assigning a group of elements to a variable automatically coerces that
>
> group of elements to a list - without problem - why doesn't 'choose from
>
> list' do the same?
>
>
>
> Should I make an enhancement request on the bugreporter, or is there a
>
> good reason for this behavior?
>
>
>
> Brennan
>
> _______________________________________________
>
> 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.
>
_______________________________________________
>
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.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.