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

Home » Public Forums » archive » Re: Help reading MAC ASCII in windows. Solution from IDL
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: Help reading MAC ASCII in windows. Solution from IDL [message #18476] Thu, 06 January 2000 00:00
Peter Brooker is currently offline  Peter Brooker
Messages: 28
Registered: July 1999
Junior Member
A solution to the CR/LF problem is to read the file 1 character at a time
and at the same time be writing another file on character at a time. When a
CR is encountered, a LF is then also written. This produces a file that can
be read by NT. The code to do this is below. Much thanks to IDL tech support
for providing this. I still am of the opinion though that "readf" should
allow you to specify what the EOL is.

PRO prepare
;This code was used to preprocess data from a MAC
;Have to use CR+LF on Windows machine

;use a native dialog to select input file
FileName = DIALOG_PICKFILE(/READ)
IF FileName EQ '' THEN BEGIN
message = DIALOG_MESSAGE('No Input File Selected!')
RETURN
ENDIF

;use a native dialog to select output file
OutFileName = DIALOG_PICKFILE(/WRITE)
IF OutFileName EQ '' THEN BEGIN
message = DIALOG_MESSAGE('No Output File Selected!')
RETURN
ENDIF

Character = 0B
CR = 13B
LF = 10B
OPENR,lun,FileName,/GET_LUN
OPENW,lun2,OutFileName,/GET_LUN
READU,lun,Character
WHILE NOT(EOF(lun)) DO BEGIN
WRITEU,lun2,Character
IF Character EQ CR THEN WRITEU,lun2,LF
READU,lun,Character
ENDWHILE

FREE_LUN,lun
FREE_LUN,lun2


END

Peter Brooker wrote:

> I am using IDL on an NT windows machine. I want to read ASCII files that
> were created on a MAC. The normal End of Line (EOL) for windows in a
> CR/LF. The MAC file only has a single CR.
>
> When IDL tries to read this type of file it gets only the first record.
> It ignors the records after the CR. Most likely it is expecting a LF.
>
> Can "readf" be set to recognize the single CR as the EOL and
> consequently read the remaining records correctly?
>
> Is there a way to tell readf that the EOL is a single CR?
>
> thanks-Peter Brooker
[Message index]
 
Read Message
Previous Topic: Re: Kudos to RSI
Next Topic: Surface Rendering from multiple 2-D images

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

Current Time: Wed Oct 08 18:52:30 PDT 2025

Total time taken to generate the page: 0.00390 seconds