Is Binfile broken?

Richard Gaskin ambassador at fourthworld.com
Tue Sep 30 12:13:04 EDT 2014


Bob Sneidar wrote:
 > I have 2 variables:
 >
 > theSourceFile which is binfile:/Users/bobsneidar/Documents/Livecode
 > Projects/Forms Generator/Installs/1105 Media Inc/Chatsworth/20140805
 >-Service Invoice.pdf
 > TheDestFile which is binfile:/Users/bobsneidar/Desktop/Install
 > Forms/1105 Media Inc/Chatsworth/20140805-Service Invoice.pdf
 >
 > I issue the command: put URL theSource into URL theDestination.
 > Nothing happens. No file gets copied. Is URL bin file deprecated??
 >
 > I then, thinking I misunderstood the put URL command, opened
 > theSourceFile (after removing the binfile: part) for binary read.
 > I then read the data until eof (the it variable shows binary data).
 > I then opened theDestFile for write (also after removing the binfile:
 > part) and wrote it then closed the file. STILL there is nothing!
 >
 > I’ve run into this before. I changed permissions to everyone write,
 > still nothing. What am I doing wrong? Here is the code:
 >
 >          open file theSourceFile for binary read
 >          read from file theSourceFile until eof
 >          close file theSourceFile
 >          put it into theSourceData
 >
 >          open file theDestFile for binary write
 >          write theSourceData to file theDestFile
 >          close file theDestFile

You're not using the URL syntax, but both the URL method and 
open/write/close should work, with both text and binary modes.

To diagnose problems with file access (and many other circumstances 
where error-checking is useful), check the result after attempting the 
action.  With file access it can be very help to include a call to 
sysError there, so you can see what the OS is complaining about, .e.g:

     open file theDestFile for binary write
     if the result is not empty then
         answer the result &"("& sysError() &")"
     end if


-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list