All of the other posts are correct, but if I'm not
mistaken, I believe you wanted to bypass a block of
code if there is an error.
Without Try-Catch, there are only two ways I can
think of to accomplish this:
1- Encapsulate each code line with an error test
(not quite the spirit of your request)
-or-
2- Call out to a block of code in a
function/procedure/method from within
the scan...endscan (My preference)
Here's some kludge code showing the concept:
CLEAR
LOCAL lcCurErrHand
lcCurErrHand = ON("error"
CREATE CURSOR test (red N(3), green N(3), blue N(3), cText c(60))
FOR i = 0 TO 255
INSERT INTO test (red, green, blue, cText) VALUES ;
(i, ;
IIF(MOD(i,20)==0,500,i), ;
IIF(MOD(i,20)==0,300,i), ;
IIF(MOD(i,20)==0,"This record will cause an error","Good record "+ALLT(STR(i))))
NEXT
gnError = 0 && Just as an example
ON ERROR Err_Hand(ERROR(), MESSAGE(), MESSAGE(1), PROG(), LINENO(), @gnError)
GO TOP
SCAN
DO TheCode && Call the inner scan code
IF gnError <> 0 && Did we get an error?
?
? "Got an error"+STR(gnError)," at record ",RECNO()-1
?
gnError = 0
ENDIF
ENDSCAN
ON error &lcCurErrHand
PROCEDURE TheCode
LOCAL lcRGB
* Error trap will catch errors caused by any
* command that follows
lcRGB = RGB(red,green,blue)
? "RGB value",lcRGB," "
?? cText
ENDPROC
FUNCTION Err_Hand(nErr, cMsg1, cMsg2, cProg, nLin, lnGlobalErr)
lnGlobalErr = nErr
DO CASE
CASE lnGlobalErr == 11 && Function argument value, type, or count is invalid.
* Find the process that's above the procedure that
* caused the error in the call stack
LOCAL i, lcReturnTo
i = 0
DO WHILE SYS(16,i) <> "ON.."
i = i + 1
ENDDO
lcReturnTo = SYS(16,i-2)
RETURN TO &lcReturnTo
OTHERWISE
MESSAGEBOX("Un-Anticipated Error",16,"Bomb!"

susp
CANCEL
ENDCASE
ENDFUNC
Darrell
'We all must do the hard bits so when we get bit we know where to bite'
