Is Binfile broken?

Bob Sneidar bobsneidar at iotecdigital.com
Tue Sep 30 13:25:28 EDT 2014


Thanks Richard. I get “Can’t open that file.” in the result for the write. Very informative. ;-)

Now I have to figure out *why* it can’t open that file. I fear it might be Mavericks sandboxing that is getting in the way. It is a folder on my desktop, and while I changed the Everyone permissions to write, it still seems to be giving me fits.

Bob S


On Sep 30, 2014, at 09:13 , Richard Gaskin <ambassador at fourthworld.com<mailto:ambassador at fourthworld.com>> wrote:

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<mailto:Ambassador at FourthWorld.com>                http://www.FourthWorld.com<http://www.fourthworld.com/>

_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list