Stop \ Error Trapping

LBiddiscombe

New Member
I have logic in place similar in structure to that shown below, but what I'd like to do is log the problem and move on to the next record.

DEFINE VARIABLE l-complete AS LOGICAL NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
my-block:
DO i = 1 to 10 ON STOP UNDO my-block, LEAVE my-block:
l-complete = FALSE.
IF RANDOM(1,20) = 1 THEN STOP. /* some useful code would be here */
l-complete = TRUE.
END.
IF NOT l-complete THEN DO:
MESSAGE "my-block failed"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.

I can easily move on to the next iteration by using NEXT my-block, but how do I log the error and then move on.

I'd like to do something like this...
DO ON ERROR PUBLISH stdErrorLogic:
or DO ON STOP PUBLISH stdStopLogic:

Does anyone have any ideas?

Thanks
 

Jens

New Member
Hello,

Try something like this:
DEFINE VARIABLE i AS INTEGER NO-UNDO.
loop:
DO i = 1 TO 20 ON STOP UNDO, RETRY:
IF RETRY THEN DO:
/* Log your error */
MESSAGE "Error in line " i VIEW-AS ALERT-BOX.
/* Jump to next */
NEXT loop.
END.

/* Sometimes create STOP */
IF RANDOM(1,5) = 1 THEN DO:
STOP.
END.
DISP i.

END.

Good luck!

Regards Jens
 
Top