comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Continuing trouble with ASCII file. Trouble with line ends
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Continuing trouble with ASCII file. Trouble with line ends [message #18491 is a reply to message #18487] Thu, 06 January 2000 00:00 Go to previous messageGo to previous message
Peter Mason is currently offline  Peter Mason
Messages: 145
Registered: June 1996
Senior Member
peter brooker <ra5589NOraSPAM@email.sps.mot.com.invalid> wrote:
> ...The problem I am having has something to do with how the file
> represents a line end/carriage return. The line end is not being
> interpreted correctly by IDL.
<...>
> Other editors such as MSWord recoginze the line end character.
<...>

Well, those ASCII files of yours sure are putting up a good fight!
I once came across an "ASCII" format that used character 13 ("carriage
return") as a line terminator and experienced similar problems to
yours. I wasn't inclined to get too fancy with a solution and so
resorted to steam power as well, but with *automated* coal shoveling.
I modified my reader to do the following:
1] Read the entire file into a byte array BDAT.
2] Replace all bytes in BDAT that have value=13b with value 10b
(a.k.a. "line-feed" - something that IDL understands to mean "end of
line")
3] Write the modified BDAT to a temporary file.
4] Business as usual with the temporary file, which is now really ASCII.
5] Delete the temporary file.

Parts 1-3 look like this:
Openr,u,fname,/get_lun,/noautomode
N=fstat(u) &n=n.size
Buf=bytarr(n)
Readu,u,buf
Free_lun,u
;
J=where(buf eq 13b,tc)
If tc gt 0L then buf[temporary(j)]=10b
;
Openw,u,'just.pvisiting',/noautomode,/get_lun
Writeu,u,temporary(buf)
Free_lun,u

Part 4 starts like this:
Openr,u,'just.visiting',/noautomode,/get_lun,/delete
..and then it's over to you.

Part 5 takes care of itself when you FREE_LUN,U at the end.


I'd recommend that you dump the first, say 120 bytes of one of your
files and see what your rogue character is. (e.g., Use the section of
code above except specify BUF=BYTARR(120<n) and then just have an extra
line that does PRINTF,BUF after the read.) It might not be character
13 as it was in my case.


Good luck,
Cheers
Peter Mason


Sent via Deja.com http://www.deja.com/
Before you buy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IMDISP Update
Next Topic: Re: Recovery from PostScript file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 08:28:03 PDT 2025

Total time taken to generate the page: 0.32325 seconds