0

I have an IDL routine that reads a binary data file. However, on this occasion, i'm getting "READU: End of file encountered. Unit 2, File: data.dat".

Instead of destroying the binary file and re-creating it. Is this problem surmountable? What IDL code could I use to allow me to read the binary file? The binary file was created by a C function.

Thanks in advance.

jpw
  • 44,361
  • 6
  • 66
  • 86
stars83clouds
  • 795
  • 1
  • 8
  • 25
  • Can you clarify what you mean by "IDL"? – Dai Aug 10 '13 at 02:05
  • @Dai Almost certain that IDL refers to [IDL (programming language)](https://en.wikipedia.org/wiki/IDL_%28programming_language%29), I changed the tag to reflect that. – jpw Aug 10 '13 at 04:01
  • Could you provide more information on the contents of the file? What did your C code write into it? Could you paste your IDL code that reads it? – shouston Aug 20 '13 at 20:11

1 Answers1

0

Based on the question, I'm assuming the binary file has a defined structure. You can probably use fstat() and eof() to get around this. For example:

openr, lun, 'file.bin', /get_lun
fs = fstat(lun)

len = fs.size / n_bytes_in_data_structure
for i = 0L, len - 1 do begin
    readu, lun, var
    ...

If you don't know the size of your data structures or if you want to check that there's a sufficient number of bytes before a read, you can use fs.cur_ptr (after a call to fstat(), of course) or eof(lun).

sappjw
  • 373
  • 1
  • 14