compress & decompress

Richard Gaskin ambassador at fourthworld.com
Sat Mar 28 13:22:01 EDT 2015


  Dr. Hawkins wrote:

 > On Thu, Mar 26, 2015 at 6:52 PM, J. Landman Gay wrote:
 >
 >> Is the file opened as a binary file?
 >
 > For writing, yes.
 >
 > It isn't opened on read; i just put the url:

Use binary for both.

Writing in text mode (which IIRC is the default in all xTalks except 
SuperCard) will convert line endings from the internal convention of 
0x10 to whatever is appropriate for the host OS.

Reading does the same in reverse.

To preserve data unaltered, use the binary form explicitly, either:

    open file tSomeFilePath for binary read
    read it until EOF
    put it into tData

...or:

    put url ("binfile:"& tSomeFilePath) into tData


Trivia question for Jacque or other HyperCard fans who might now:  did 
reading in HyperTalk also strip NULL bytes, or convert NULLs to spaces? 
  LiveCode doesn't, but I had thought I'd heard that HC did.

-- 
  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