Page 1 of 1

Drag & Drop muddle

Posted: Fri Jul 19, 2013 1:08 pm
by user#606
I have a problem coding with drag & Drop, can someone help please?

What I need to achieve (outline)
1/ drag and drop a file into a text field so the full path is contained in it.
for this I have used:-
on dragDrop
put the dragData["files"]into field "TemplatePaths" --Dragged data in limbo
put empty into field "TemplatePaths" --Makes sure field is empty
pass dragdrop --The DRAGDATA is now out of limbo and put into field "TemplatePaths"
end dragDrop
2/ move the file from the address in field "TemplatePaths" to a different, pre-determined folder, using:-
-- Move file
--First get path to COPY FOLDER
set itemdelimiter to "/" --so end, back to / can be found
put field "FilePath" into Temp --The field "FilePath" contains the application folder path and app file name
delete the last item of Temp --removes the application file name and leaves the path
create folder ( Temp & "/Templates") --In case there is no such folder called "Templates"
answer ( Temp & "/Templates") -- this shows the code gives the correct answer.

put temp & "/Templates/"& the last item of field "TemplatePaths" into Temp --create a Copy File path
revCopyFile field "TemplatePaths",temp --Copy from Original path , into New path
delete file field "TemplatePaths" --Original path

How do I make the code in item 2 work after item 1 has been processed?
I do not want to use a button, just one operation where item 1 and 2 are combined.

Re: Drag & Drop muddle

Posted: Fri Jul 19, 2013 6:49 pm
by Simon
Hi user#606,
I've had troubles using revCopyFile in the past.
try:
put url("file:" & field "TemplatePaths") into tFile
put tFile into url("file:" & temp)

I think I got you vars correct.
Might be "binfile:" instead of "file:" depending on if it's a text or binary file.

Looking through some scripts of mine I see that I sometimes just use:
put url(path-to-file)
Without the "file:" Maybe you could tell me if both work for you?

Simon