RE: Problem with binary files
- Posted by rforno at tutopia.com Apr 30, 2001
- 490 views
Thanks a lot. It was not part of the problem, but *the* problem. Sometimes one has to read the reference manual completely. Of course, I knew that #0D #0A was \r\n, but I was unaware of the several open() formats. ----- Original Message ----- From: Travis Beaty <travisbeaty at arn.net> Subject: Re: Problem with binary files > > > Howdy! > > Part of your program may be that you are not opening the file as a binary file. The combination > #0A#0D is "\r\n." Instead of > > f = open("zz", "w") > > try > > f = open("zz", "wb") > > and see if that gets its act straight. > > -- Travis -- > > > 4/28/2001 10:43:32 PM, rforno at tutopia.com wrote: > > >I am working in a program that generates MIDI files. After getting strange > >results, I traced the problem to the puts() command. It keeps generating #0D > >characters before each #0A. The program was run under DOS under Windows 98. > >The reduced test program is very simple: > >procedure test() > > integer f > > sequence s > > f = open("zz", "w") > > s = {} > > for i = 0 to 2 do > > for j = 0 to 255 do > > s &= j > > end for > > end for > > puts(f, s) > > close(f) > >end procedure > >test() > >I am attaching the output of this program. > >Does anybody know how to get rid of the extraneous #0D characters? > > > > > >