how to copy files?

Ben Rubinstein benr_mc at cogapp.com
Wed Jan 16 13:34:01 EST 2002


on 16/1/02 4:29 PM, Roger.E.Eller at sealedair.com at
Roger.E.Eller at sealedair.com wrote:

> put URL "file:C:/myFile.txt" into "file:C:/myCopiedFile.txt"

Depending on your needs, this may work fine; but note that it is not a
general solution.

It amounts to 'read text of source file into memory', 'write that text out
to a destination file'.  The file must fit into Revolution's memory, and the
destination file may be different from the source file (because Revolution
may switch line end markers, and possibly (?) high-ascii characters).

You can partially fix the second problem using the "binfile:" 'protocol'
instead of "file:", ie

    put URL "binfile:C:/myFile.txt" into "binfile:C:/myCopiedFile.txt"

Revolution will still need enough memory to hold the contents of the file.
With a bit more effort you can avoid the memory problem, using the
open/read/write/close commands instead of the URL syntax to read the source
file a bit at a time, write that bit out, and continue.

Finally, if this needs to work for arbitrary files on MacOS, note that any
of the above will only ever read the data fork of a file; so depending on
the files you want to copy, you may still lose data using any of the
variations of this approach noted above.

So the only completely general solution is to avoid the approach of reading
data into, and writing it back out of, Revolution.  You can do this using
the "shell" command on Windows and *nix, and using AppleEvents to instruct
the Finder on MacOS.

... but all of this may not be necessary - just depends on what you need.
 
  Ben Rubinstein               |  Email: benr_mc at cogapp.com
  Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
  http://www.cogapp.com        |  Fax  : +44 (0)1273-728866





More information about the use-livecode mailing list