X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 19 Dec 2007 08:03 PM by  anon
Some more about the CATCH procedure
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
19 Dec 2007 08:03 PM
    Hi, Back on the CATCH procedure I encounter some problem with a very simple algorithm The following code: PRO Continue_On_Error I = SHIFT(INDGEN(10), -5) F = INTARR(9) FLAG=0 ; Cause an error when K eq 4: FOR K=0,10 DO BEGIN CATCH, Error_Status IF Error_status NE 0 AND FLAG EQ 0 THEN BEGIN PRINT, 'In the Catch Loop' K=K+1 FLAG=1 CATCH, /CANCEL ENDIF F[I[K]]=K PRINT, K, I[K] ENDFOR END Outputs the following log: % Compiled module: CONTINUE_ON_ERROR. % Compiled module: CONTINUE_ON_ERROR. 0 5 1 6 2 7 3 8 In the Catch Loop 5 0 6 1 7 2 8 3 9 4 After that, IDL prompt kept busy for ages and I need to kill IDL if I want to be able to work with it ! I don't understand why this is happening ? Any idea ? Best Regards. Antoine C.

    Deleted User



    New Member


    Posts:
    New Member


    --
    19 Dec 2007 08:03 PM
    I am not taking the time to run the code right now, but I bet your problems will not be solved until you implement an important programming principal for CATCH statements: If you initialize a CATCH statement within a loop, make sure to CANCEL that CATCH statement at every exit point of the cycle. I DO believe that the code you have right now is loading an additional error handler in your running program every time the code cycles through the FOR loop without error. I bet that the error you trigger cancels one of these, but none of the others. Eventually, I suspect that there is some disconnect between the CATCH that is being CANCELled and the one that starts to infinitely fail at your 'F[I[K]]=K' line. Implementing this codig principle is in any case the place to start. Let the Forum know if that solves the problem. James Jones ITT Technical Support
    You are not authorized to post a reply.