Drag & Drop muddle
Posted: Fri Jul 19, 2013 1:08 pm
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.
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.