Re: are finder items items? what is a vector?
Re: are finder items items? what is a vector?
- Subject: Re: are finder items items? what is a vector?
- From: Axel Luttgens <email@hidden>
- Date: Fri, 25 Dec 2009 14:48:55 +0100
Le 23 déc. 2009 à 22:44:23, Brennan a écrit :
> [...]
>
> My script so far:
>
> tell application "Finder"
>
> set inverted to {}
>
> set fitems to items of window 1
>
> repeat with i in fitems
>
> if i is not in selection then
> set end of inverted to i
> end if
>
> end repeat
>
> set selection to {}
> select inverted
>
> end tell
>
> I am getting stuck on the 'if' line - being told things like
>
> Can’t make «class cfol» "Address Book Plug-Ins" of «class cfol» "Library" of «class sdsk» of application "Finder" into type vector.
>
> [...]
Hello,
The "is in" operator is applied here to lists: a list contains another one if the latter is a sublist of the former.
The operator thus expects two lists as operands.
The error message tells that the "Finder item to list" coercion is an unknown operation.
So, being explicit:
if {i} is not in selection then
allows to avoid that error message.
But... above test appears to be always true.
And indeed, one is now facing the fact that i, being the loop variable of a "repeat with variable in list" loop, is a reference of the form "item x of fitems", not the xth item of fitems itself. {i} is thus a list containing a reference, not a list containing a Finder item.
As a result, one needs:
if {contents of i} is not in selection then
and the script now behaves as expected.
HTH,
Axel
_______________________________________________
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