Drag & Drop muddle

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

Drag & Drop muddle

Post by user#606 » 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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Drag & Drop muddle

Post by Simon » Fri Jul 19, 2013 6:49 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply