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: 510-215-4224 FAX:510-215-4299 _______________________________________________________________