Re: Skipping a line while reading a file. [message #15545] |
Fri, 21 May 1999 00:00 |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
DBorland wrote:
>
> Greetings,
> I am trying to read in some data from a file, and there is a blank line in
> the file. This would not be a problem if the next line I needed to read was
> not a string. Is there any way to have idl skip a line while reading a
> file?
> Here is an example of the data file:
> [... snipped]
> and I am reading it in with the following:
> for i = 0, n-1 do begin
> readf,lun,index,hex_address,angle,magnitude,potential,area
> readf,lun,location
> readf,lun,outward_normal
> readf,lun,address
> : : :
> endfor
>
apparently you don't assign any variable type before you read them. This
can cause all sorts of trouble. As David suggested, you can (only !)
read a string variable if you let IDL know beforehand that it has to
expect a string:
line = ''
readf,lun,line
Careful also with long integers! It never hurts to write
number = 0L
readf,lun,number
... maybe IDL should have an IMPLICIT NONE option ??
Regards,
Martin
--
|||||||||||||||\\\\\\\\\\\\\-------------------///////////// //|||||||||||||||
Martin Schultz, DEAS, Harvard University, 29 Oxford St., Pierce 109,
Cambridge, MA 02138 phone (617) 496 8318 fax (617) 495 4551
e-mail mgs@io.harvard.edu web http://www-as/people/staff/mgs/
|
|
|
|