Re: unexpected EOF? [message #19703] |
Wed, 12 April 2000 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Kyung Byun (kbyun@fas.harvard.edu) writes:
> I have a function that is supposed to take a text file and remove the
> top few lines and bottom lines (I'm trying to extract the middle bunch
> of lines in the text...the files I'm feeding this function are all
> basically the same format). I'm running the program and on the
> readf, ... line I'm getting the following message:
> % READF: End of file encountered. Unit: 101, File: HEFTmimic2.ef
> % Execution halted at: STRIP 27 /data/mlf2/area/2conefolder/oplot_eax.pro
> % $MAIN$ 79 /data/mlf2/area/2conefolder/oplot_eax.pro
> ie, IDL is telling me that the file I'm feeding into it ('HEFTmimic2.ef')
> has an EOF at the beginning of the file (?!) that is preventing it from
> going further. The file 'HEFTmimic2.ef' is not empty, so I don't know
> what the message means.
No, I think IDL is trying to tell you that you aren't
doing what you *think* you are doing, but I don't
know why it always chooses this esoteric message
to do so. I would prefer something like "Oh, come
on. Get real!"
The problem here is that IDL *always* reads to the
end of the line when reading into a string variable.
It looks to me like you are reading about twice as
many lines of text as you are intending to read.
Hence, you are reading past the end of file mark.
(Oh, well, I guess that message *does* make
some sense.)
I would define "allarray" like this:
allarray = StrArr(alllines)
Then I would look for the word "ENERGY" in just
the first 6 characters of each line, as you are doing
now.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|