Le 11 mai 2012 à 04:33, Jim Skibbie a écrit :
I have a script that has been working without issue under OS X 10.4 and 10.5. Recently, some users have upgraded to OS X 10.6.8, and now the script does not work.
Basically, the script tries to see if a file is already in the DroppedFiles list of aliases, and if it isn't, it adds it, but under OS X 10.6.8, it fails the condition and adds an alias to the DroppedFiles list even though it already exists in DroppedFiles.
Here's an example:
on open DroppedFiles
-- the variable DroppedFiles is a list of aliases
--{alias "SnowLeopard Drive:some file.pdf", alias "SnowLeopard Drive:some other file.pdf"}
set x to "SnowLeopard Drive:some file.pdf"
try
set x to x as alias
display dialog ((DroppedFiles does not contain x) as string)
display dialog (((DroppedFiles as string) does not contain (x as string)) as string)
if DroppedFiles does not contain x then
display dialog ("I should not get here." & return & return & "Files dropped: " & return & DroppedFiles as string) & return & return & "File coerced to alias: " & return & (x as string)
end if
end try
end open
I am unable to test under 10.6.8 so I tested under 10.7.4 (Apple Script Editor).
I added some instructions to check the class of passed items.
I got :
on open DroppedFiles
-- the variable DroppedFiles is a list of aliases
--{alias "SnowLeopard Drive:some file.pdf", alias "SnowLeopard Drive:some other file.pdf"}
set x to "Macintosh HD:Users:yvankoenig:Desktop:green pisse.pages:"
display dialog "" & class of item 1 of DroppedFiles
-- > «class bmrk »
tell application "Finder"
set DroppedFiles to DroppedFiles as alias list
end tell
display dialog "" & class of item 1 of DroppedFiles
-- > «class bmrk »
try
set x to x as alias
display dialog "" & class of x
--> alias
display dialog ((DroppedFiles does not contain x) as string)
display dialog (((DroppedFiles as string) does not contain (x as string)) as string)
if DroppedFiles does not contain x then
display dialog ("I should not get here." & return & return & "Files dropped: " & return & DroppedFiles as string) & return & return & "File coerced to alias: " & return & (x as string)
end if
end try
end open
So, it's normal that your comparison fail.
DroppedFiles is not seen as a list of aliases but a list of «class bmrk» objects.
What is really puzzling is the fact that they remain of this kind after coercing the list « as alias list »
Yvan KOENIG (VALLAURIS, France) vendredi 11 mai 2012 08:19:27