Page 1 of 1

XP revCopyFile weirdness

Posted: Sun Nov 14, 2010 9:08 pm
by pkocsis
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?

Re: XP revCopyFile weirdness

Posted: Thu Nov 18, 2010 3:27 am
by Mark
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

Re: XP revCopyFile weirdness

Posted: Thu Nov 18, 2010 2:57 pm
by shaosean
Too bad AppleScript is only the Mac so that does not explain the weirdness he is seeing..

Re: XP revCopyFile weirdness

Posted: Thu Nov 18, 2010 3:01 pm
by Mark
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

Re: XP revCopyFile weirdness

Posted: Sat Nov 20, 2010 9:54 am
by pkocsis
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