[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: to R. Bauer

TTs <TTs@newsguy.com> wrote:
> In article <369CED49.F40D6668@fz-juelich.de>, "R.Bauer" says...
> >
> >> Using IDL 5.1 in a PentiumII NT 4.0 box this line of code:
> >>
> >>         for i=0L, 307199 do printf, wlun, image(i), format='(I1)'
> >>
> >>   create files with RETURN (\r) and LINE FEED (\n) terminations...
> >>
> >> How could I modify this so just RETURNS (^M)  is used to finish the lines?
> >
> >Use the binary key with openw
> Could you plase tell me more details about this? I am a kinda of newbie with
>   IDL...

Since you posted this to the group, I'll take the liberty of joining in. I
believe that R. Bauer means the optional keyword /BINARY for the OPEN
command. Now this feature is a strong contender for the nastiest corner in
the IDL universe.  It is truly hideous.  Unspeakable.  A shock to one's
sensibilities.	Another monument to that billionare dude. OK, sorry.  I'll
try to explain...

On Windows platforms (and not on ANY other platforms), IDL sports optional
keywords BINARY and NOAUTOMODE for the OPENU (open existing file for update)
command.  (The docs only mention these keywords for OPENU, but they appear to
work for OPENW as well.  Haven't bothered to verify OPENR.)  The default when
you open a file for update is that it happens in "text mode" - and this means
that <CR><LF> pairs in the datastream are UNAFFECTED.  (This will come as a
bit of a disappointment to anyone who might have used UNIX or even just FTP.)
 If you OPENU/BINARY it's supposed to turn on filtering of <CR><LF>, maybe. 
The thing is, if you then use PRINTF it'll (reportedly) flip the thing to
"text mode".  So it looks like /BINARY on its own won't cut it.  You have to
do OPENU,/BINARY,/NOAUTOMODE to get the filtering to happen.

There it is - that's essentially what's in the online manual, and that's what
appears to happen.  I normally get it the wrong way round, but I do believe I
have the contortions right this time.  Basically this whole arrangement is so
fishy and ill-explained that most of us just try to avoid it or pretend that
it isn't there.

BTW, this filtering will strip out the <CR>s (char(13)) in <CR><LF> pairs,
leaving just the <LF>s (char(10)).  Unix style.  I don't know about stripping
out <LF>s.

Peter Mason.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own