Re: skip the corrupted hdf file and continue the for lood for uncorrupted hdfs [message #87350 is a reply to message #87349] |
Mon, 27 January 2014 01:25   |
Yngvar Larsen
Messages: 134 Registered: January 2010
|
Senior Member |
|
|
On Monday, 27 January 2014 09:22:26 UTC+1, Brent Fallarcuna wrote:
> My question is, can I continue my for loop and proceed reading the other uncorrupted hdf files every time I got the said error?
>
> I've tried catch statement but I can't figure it out on how to use and implement it correctly.
>
The solution should involve CATCH. Something like this:
for i=0, nfiles-1 do begin
;; Establish error handler
catch, error
if error ne 0 then begin
print, filename[i]
print, !error_state.msg
;; continue with next item in loop if error was encountered
catch, /cancel
continue
endif
hdf_id = hdf_sd_start(filename[i])
catch, /cancel
;; Do other stuff with file here if no error was encountered.
;; ...
endfor
--
Yngvar
|
|
|