On Nov 10, 11:23 am, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
> bulrushmo...@gmail.com schrieb:
>
>
>
>
>
>> On Nov 10, 7:38 am, David Fanning <n...@dfanning.com> wrote:
>>> Spon writes:
>>>> bulrushmo...@gmail.com writes:
>>>> > How can I set up that when error happens, IDL output the error message
>>>> > to log file, then igonore that step continue to process next data?.
>>>> Something like this:
>>>> OpenW, lun, 'logfile.out', /GET_LUN
>>>> FOR j=0,n DO BEGIN
>>>> Catch, theError
>>>> IF theError NE 0 THEN BEGIN
>>>> PrintF, lun, 'Problem with processing step ' + StrTrim(j)
>>>> CONTINUE
>>>> ENDIF
>>>> DoSomeProcessing, data[j]
>>>> ENDFOR
>>>> Catch, /Cancel
>>>> Free_Lun, lun
>>>> Excuse my ignorance on this, but wouldn't you need to stick your
>>>> "Catch, /Cancel" INSIDE the for loop?
>>>> If not, why not?
>>> There is no requirement for when you cancel a CATCH, except
>>> you should cancel it when you are finished with it. While CATCH
>>> is in effect, any error is re-routed to the first line after
>>> the CATCH statement. When cancelled, any error is routed
>>> to the ON_ERROR condition in effect for that program
>>> module. In a real code example, rather than cancelling
>>> the CATCH there, I would probably have had another CATCH
>>> statement to replace the one I was using for the process
>>> loop.
>
>>> Cheers,
>
>>> David
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")- Hide quoted text -
>
>>> - Show quoted text -
>
>> The problem is even I use these statements, program still halted when
>> enounter a bad data.
>> Should I place the Catch, /cancel inside the loop.
>> Another issue, should I state the Catch, the error right after the
>> beginning the loop, or after the image processing, end of the loop?
>
>> thanks
>
> If you can show your source, e.g. use a pastebin
> we usually can better help
>
> cheers
> Reimar- Hide quoted text -
>
> - Show quoted text -
Here is my source code. I am using MCTK tool to convert MODIS HDF
data. The data processing is just converting the projection. It always
runst for nearly a hundred data, then stops, saying 'can not attach
the grid file...etc'. I would like to have the code right down the
error in the log file, and then continue the loop for the next data.
Thanks
Pro convert_test
out_path = 'define the path here'
in_path = 'define the path here'
envi, /restore_base_save_files
envi_batch_init, BATCH_LUN=batch_unit, log_file = out_path +
modisdata.txt'
files = file_search(in_path, '*.HDF', count=count)
FOR i = 0, count-1 do begin
CATCH, Error_status
IF Error_status NE 0 THEN BEGIN
printF, batch_unit, 'Error index: ', Error_status
printF, batch_unit, 'Error message: ', !ERROR_STATE.MSG
PrintF, batch_unit, 'Problem with processing step ',
files[K]
CONTINUE
Catch, /Cancel
ENDIF
modis_grid_file = files[i]
variable = variable
......
convert_modis_data, variable=variable,...
ENDFOR
end
|