Re: Catching I/O errors on RESTORE [message #29698 is a reply to message #29688] |
Sat, 09 March 2002 23:40   |
alt
Messages: 28 Registered: August 2001
|
Junior Member |
|
|
I have the similar problem while organizing simple IDL client-server
applications. Suppose client is trying to read sav-file before server
end up with writing...
Some possible useful ideas:
* CATCH (not ON_IOERROR) catches all errors including RESTORE errors
(unfortunately not all)
* FILE_TEST() checks file existence without opening it.
* file size can be obtained via (FSTAT(f)).SIZE
* FILE_INFO() (only in IDL 5.5) can get file size without opening it.
* sometimes (very rare) RESTORE can not restore all saved variables
and restore only part of them messaging "Truncating..." and CATCH does
not catch this situation (AFAIK). So I recommend to use CMSVLIB
library of Craig B. Markwardt
(http://cow.physics.wisc.edu/~craigm/idl/cmsave.html) which he kindly
grants to IDL community.
Best regards,
Altyntsev Dmitriy
Remote Sensing Center, ISTP
Irkutsk, Russia
http://ckm.iszf.irk.ru
MKatz843@onebox.com (M. Katz) wrote in message news:<4a097d6a.0203081046.1deaf7e@posting.google.com>...
> Here's in I/O error-trapping question for the IDL gurus out there...
>
> Working in IDL 5.4 on SunOS UNIX, I'd like to catch errors
> that occur when reading a bad or incomplete--but existing--
> IDL SAVE file. I want to use ON_IOERROR, but it doesn't
> seem to catch errors that occur with the RESTORE function.
> Here's more information...
>
> I create a smallish (100-200 bytes) disk file with
>
> SAVE, x, y, z, filename="myfile.dat"
>
> Since I have lots of programs running simultaneously, different
> parts of my program or different IDL sessions may be
> SAVEing and RESTOREing these files in quick succession.
>
> Before I RESTORE, I always check for the existence of the file with
> FRELUN, 10
> OPENR, 10, filename, ERROR=err
>
> Sometimes, the file exists but is empty (!), then IDL tries to RESTORE
> and comes back with an END OF FILE error.
>
> SO, I put in an error catcher:
>
> ON_IOERROR, error_label
>
> Yet the program still halts with an END OF FILE, and the error
> trap is never activated. Any ideas?
> I would like the RESTORE file to trip the error trap and go
> nicely to my error-handling code.
>
> Thanks, MKatz
|
|
|