Can someone of you see an error or the section causing a nasty delay

I have a script that copy files into another location, when they dropped onto an item in a drawer.

it works fine and does what it shall do, but there is dirty thing: When I drop down the files the App and the Finder hangs for 30 seconds with a spinning Beachball. After this time the App do the job and sthe state went to normal.

Can someone of you see an error or the section where this nasty delay will be produced? thx.
Michael

_start

property emptyBox : missing value
property fullBox : missing value
property fileList : {}

on loadBoxImages()
set emptyBox to load image “drag.tif”
set fullBox to load image “drop.tif”
end loadBoxImages

on setBoxImage(state)
if state is “full” then
set image of image view “dropzone” of drawer “drawer” of window “main” to fullBox
else if state is “empty” then
set image of image view “dropzone” of drawer “drawer” of window “main” to emptyBox
end if
end setBoxImage

on drag entered theObject drag info dragInfo
setBoxImage(“full”)
end drag entered

on conclude drop theObject drag info dragInfo
set image of image view “dropzone” of drawer “drawer” of window “main” to emptyBox
set preferred type of pasteboard of dragInfo to “file names”
set fileList to contents of pasteboard of dragInfo
set zielordner to “Kraftmobil_Platte:Users:mk:Desktop:mk”
repeat with currentItem in fileList
tell application “Finder”
duplicate (currentItem as POSIX file as alias) to zielordner with replace
end tell
end repeat
set preferred type of pasteboard of dragInfo to “”
end conclude drop

on drag exited theObject drag info dragInfo
setBoxImage(“empty”)
end drag exited

on drop theObject drag info dragInfo
if “file names” is in types of pasteboard of dragInfo then
return true
else
return false
end if
end drop

on awake from nib theObject
loadBoxImages()
end awake from nib

_stop

There are not errors in your code. This is an expected behaviour and I think that fix it is in Apple’s TODO list.
When the “drop” handler is reached, it executes all statements and waits for the last one (after your files were copied), usually a “return true” or “retur false”.
You could try adding a “ignoring” statement, but you’ll miss any errors…
Pseudo-code

on conclude drop blah...
     ignoring application responses
          tell app "Finder" to whatever
     end ignoring
     return true
end conclude blah

Using the “ignoring” statement, you will fire the event to the Finder and won’t wait for the copy to be finished.

I haven’t tested your code but you have a variable called “state” in one of your handlers. I’d change this to “the_state” since “state” is a property of controls in AS Studio (e.g., “set state of button 1 to 1”). Just a thought.

Jon

thx, it works fine now.

Do I miss any errors inside the whole app or only inside the repeat?

mk