Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: binary file i/o
Posted:
Aug 16, 1996 2:59 AM


William Weglinski wrote: > > I am having difficulty reading and writing binary files correctly, With Mathematica 2.2 > for Windows on my PC. The first problem is that if a file contains the byte: 1A (i.e. > hexadecimal 26), it is interpreted as EndOfFile, and I can't figure out any way to force > Mathematica to read any more bytes after that. The second problem is trying to write > the byte 0A (i.e. hexadecimal 10  a.k.a. linefeed ) to a file. Instead of writing > just the byte: 0A, the bytes: 0D0A are outputted (carriage return+linefeed). Again, I > can't find any way to override this behavior. The standard Mathematica package: > Utilities`BinaryFiles` was of no help to me, nor could I make it work using the > WriteString[] command directly. Setting the StringConversion option on the outputstream > didn't work either. Has anyone else encountered this problem, and what can be done to > work around it?
In order to work with binary files on DOS systems, you'll need to use MathLink and Todd Gayley's package FastBinaryFiles.m (from MathSource). It's the only way right now. I believe that Mma fo Win 2.2.3 finally supported MathLink. (Personally, I switched to the Mac for just that reason: to read DOS binary files into Mma).
 _______________________________________________________________ Harald Berndt University of California Research Specialist Forest Products Laboratory Phone: 5102154224 FAX:5102154299 _______________________________________________________________



