Re: skip the corrupted hdf file and continue the for lood for uncorrupted hdfs [message #87371 is a reply to message #87355] |
Tue, 28 January 2014 09:52  |
Yngvar Larsen
Messages: 134 Registered: January 2010
|
Senior Member |
|
|
On Tuesday, 28 January 2014 06:14:03 UTC+1, Brent Fallarcuna wrote:
> On Monday, January 27, 2014 4:22:26 PM UTC+8, Brent Fallarcuna wrote:
> Hello.
>
> I've run this code, wherein I inserted the for loop. The output on the command line says "MOD17A2.A2000065.h29v07.005.2010162162935.hdf
>
> Attempt to subscript FILENAME with K is out of range." and it only prints a single value.
Well. This is a rather accurate error message, because this is exactly what is going on. You (or actually I since you copied my code verbatim) made an error within the error handler. The value to print in the error handler is FILENAME or FILELIST[i], not FILENAME[i]. Of course, in your case, you most likely would like to save the name of the erroneous file in the error handler instead of just printing the name.
> catch, error
> if error ne 0 then begin
> print, filename[i] <------------ ERROR IN ERROR HANDLER
> print, !error_state.msg
> ;continue with next item in loop if error was encountered
> catch, /cancel
> continue
> endif
>
> ;access hdf file
> hdf_id = hdf_sd_start(filename[k]) <--------- ANOTHER ERROR
> catch, /cancel
>
> ;Do other stuff with file here if no error was encountered.
Also, I have no idea what you are trying to do with the double loop.
--
Yngvar
|
|
|