Re: skip the corrupted hdf file and continue the for lood for uncorrupted hdfs [message #87357 is a reply to message #87356] |
Mon, 27 January 2014 21:47   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> I would write something along these lines:
>
> filelist = file_search('*.*.h29v07.005.*.hdf', Count=count)
> array = StrArr(count)
> FOR j=0,count-1 DO BEGIN
>
> Catch, theError
> IF theError NE 0 THEN BEGIN
> void = cgErrorMsg()
> Print, 'Bad File: ', filename[j]
> Message, /Reset
> Continue
> ENDIF
>
> thisFile = filelist[j]
> hdf_id = hdf_sd_start(thisFile)
> ...
>
> ENDFOR
Whoops! I just violated the cardinal rule of error handling: Don't
introduce errors into your error handling code! Kill your IDL session
with your mouse when you get into the infinite loop I put you into, then
make this change to your code. Sorry! :-(
filelist = file_search('*.*.h29v07.005.*.hdf', Count=count)
array = StrArr(count)
FOR j=0,count-1 DO BEGIN
Catch, theError
IF theError NE 0 THEN BEGIN
void = cgErrorMsg()
Print, 'Bad File: ', thisFile
Message, /Reset
Continue
ENDIF
thisFile = filelist[j]
hdf_id = hdf_sd_start(thisFile)
...
ENDFOR
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|