X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 09 Oct 2006 12:09 PM by  anon
Controlling program after an error
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
09 Oct 2006 12:09 PM
    I'm calling the function maximization routine, DFPMIN to analyze pixels in MR images. Occassionally the routine reaches the limit of the number of iterations. I'd like to put in some error value into my image and continue with the next pixel. I don't see a way to have the program acknowledge an error has occured and continue on.

    Deleted User



    New Member


    Posts:
    New Member


    --
    09 Oct 2006 12:09 PM
    The routine for catching errors in IDL is called CATCH. I don't know much about DFPMIN, but, if its reaching the limit of the number of interations triggers an IDL error, you can implement syntax like the following, quite possibly most rationally right before the DFPMIN call: errno = 0 catch, errno if errno ne 0 then begin catch, /CANCEL ; Stop IDL from catching more errors help, !error_state, /STRUCT help, /TRACEBACK ; Useful in many cases, but not so much in this example endif DFPMIN, myX, myGtol, myFmin, myFunc, myDfunc catch, /CANCEL ; This is useful only if you want to stop error-seeking right after DFPMIN I just put HELP calls in the "catch block", but you could replace or enhance those with some calls to reset the state of some of your variables, so that DFPMIN can retry or so that it can be skipped over. Catch blocks return to the problem call right after they exit. This is a place where IDL GOTO statements (usually considered bad programming practise) may come in handy. James Jones
    You are not authorized to post a reply.