[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File pointer problem on PC-IDL



Wayne Landsman (landsman@stars.gsfc.nasa.gov) writes:

> I am trying to debug a program (a "FITS" reader) that is failing on PC-IDL 
> Unfortunately, I don't have access to PC-IDL myself so I apologizing for not 
> doing as much debugging as I would have liked before posting my problem.     
> 
> Basically, then internal file position is getting screwed up.    I open a 
> binary file, readu 2880 bytes, and find myself located 4095 bytes into the 
> file.   Below is the simple script (as done by a remote user with PC-IDL).
> 
> IDL> print, !version
> { x86 Win32 Windows 5.2 Oct 30 1998}
> 
> IDL> openr,lun,'C:\burst_image_1.fit',/block,error=error,/get_lun
> IDL> if eof(lun) then message, 'Reached end of file'
> IDL> buf = replicate(32b,80,36)                    ;Total of 2880 bytes
> IDL> readu,lun,buf 
> IDL> help,/str,fstat(lun)
> ** Structure FSTAT, 12 tags, length=36:
>    UNIT            LONG               100
>    NAME            STRING    'C:\ROTSE\GRB 990123\burst_image_1.fit'
>    OPEN            BYTE         1
>    ISATTY          BYTE         0
>    ISAGUI          BYTE         0
>    INTERACTIVE     BYTE         0
>    READ            BYTE         1
>    WRITE           BYTE         0
>    TRANSFER_COUNT  LONG              2880
>    CUR_PTR         LONG              4095
>    SIZE            LONG             25920
>    REC_LEN         LONG                 0

There is definitely something about that EOF function
that is moving the file pointer, even though nothing
indicates that it is (I.e., an FSTAT right after the
EOF function indicates that the file pointer is at
0.) This has the feel of a bug to me. (Removing the 
BLOCK keyword on the OPEN statement didn't affect the
problem.)

A simple:

   Point_Lun, lun, 0

after the EOF command will fix whatever ails it. 

Let us know what you find out from RSI.

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

[Note: This follow-up was e-mailed to the cited author.]