XP revCopyFile weirdness

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pkocsis
Posts: 105
Joined: Sat Apr 15, 2006 7:20 am

XP revCopyFile weirdness

Post by pkocsis » Sun Nov 14, 2010 9:08 pm

anyone know why revCopyFile at times might return '1' in the result?

src file definitely exists as well as destination directory.

When doing something like the following:

Code: Select all

revCopyFile tsrcfile,tdestdir
if the result is not empty then
   wait for 100 milliseconds with messages
   revCopyFile tsrcfile,tdestdir
   if the result is not empty then
      wait for 100 milliseconds with messages
      revCopyFile tsrcfile,tdestdir
      if the result is not empty then
         put "DIDN'T WORK"
      else
         put "WORKED! #3"
      end if
   else
      put "WORKED! #2"
   end if
else
   put "WORKED! #1"
end if
on XP, if I call this routine to copy files, most of the time it returns "WORKED! #1"....but SOMETIMES it returns "WORKED! #3"???

Further checking seems that when copy attempt 1 and 2 don't work, the result is '1'

It is intermittent and has me puzzled. I have further tested revCopyFile and it seems that the only time I can get a '1' in the result is if the src file does not exist. I just don't get what is going on here?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: XP revCopyFile weirdness

Post by Mark » Thu Nov 18, 2010 3:27 am

Hi pkocsis,

revCopyFile is unreliable. It uses AppleScript and has insufficient error handling. Also, the script under the hood is very old and may be using obsolete AppleScript syntax. There are several ways to do this:

1) put url x into url y
2) use the open file, read from and write to commands
3) as 2) but in small chunks inside a repeat loop with messages
4) create your own AppleScript with sufficient error handling
5) use the cp shell command

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: XP revCopyFile weirdness

Post by shaosean » Thu Nov 18, 2010 2:57 pm

Too bad AppleScript is only the Mac so that does not explain the weirdness he is seeing..

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: XP revCopyFile weirdness

Post by Mark » Thu Nov 18, 2010 3:01 pm

shaosean, you're right. On Windows, it is probably some DOS command that is being used. I don't know where the "1" comes from, but the solution stays the same. If trying the shell on Windows, use copy instead of cp.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pkocsis
Posts: 105
Joined: Sat Apr 15, 2006 7:20 am

Re: XP revCopyFile weirdness

Post by pkocsis » Sat Nov 20, 2010 9:54 am

Thank you to all that have replied!

I have since punted on revCopyFile and instead am using put url tsrc into url tdest. This has mitigated my problem, but just for a further FYI...

I have found that sometimes revCopyFile will return '1' and yet the COPY OPERATION DID INDEED WORK!? So sometimes i'll get a '1' as the result and the copy has indeed failed, and sometimes I'll get a '1' and the copy did indeed work. I have not experienced an empty result with a failed copy, but I have abandoned the use/testing of revCopyFile in favor of my above statement using url. I have not had any further issues since I have been using put url tsrc into url tdest.

Thanks again to all!

Paul

Post Reply