on open DroppedFiles
-- the variable DroppedFiles is a list of bookmarks
--{«class bmrk» "SnowLeopard Drive:some file.pdf", «class bmrk» "SnowLeopard Drive:some other file.pdf"}
tell application "Finder" to set DroppedFiles to (the selection as alias list)
set x to "Macintosh HD:Users:yvankoenig:Desktop:green pisse.pages:"
try
DroppedFiles does not contain (x as alias)
display dialog "test #1 : " & result
set {oTids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set Dropped_Files to DroppedFiles as text
set AppleScript's text item delimiters to oTids
DroppedFiles as text does not contain x
display dialog "test #2 : " & result
if DroppedFiles does not contain (x as alias) then
display dialog ("I should not get here." & return & return & "Files dropped: " & return & DroppedFiles & return & return & "File coerced to alias: " & return & x)
end if
end try
end open
With this code, the list of dropped files is not the one received by the droplet, it's the list of selected items which contain the same items but in an other format.
This time both tests behave flawlessly.
I don't know which is wrong.
or the AppleScript's User Guide which describes wrongly what is passed to on open handlers.
open Handlers
Mac OS X applications, including script applications, receive an open command whenever the user drops
file, folder, or disk icons on the application’s Finder icon, even if the application is already running.
If the script in a script application includes an open handler, the handler is executed when the application
receives the open command. The open handler takes a single parameter which provides a list of all the items
to be opened. Each item in the list is analias (page 79) object. [ the typo (missing space) is in the Guide]
Yvan KOENIG (VALLAURIS, France) vendredi 11 mai 2012 14:59:37