BUFFER-VALIDATE and NO-ERROR

remik

New Member
HALLO!
I have created new row by BUFFER-CREATE()
and after writing values to fields i wanted to validate new row.

Validation with BUFFER-VALIDATE is ok when record is valid - it retrurns true, but when new record is not valid progres throws error message.

I'd like to menage this error by myself, but 'NO-ERROR' - don't work here :

result = bufferTable:BUFFER-VALIDATE() NO-ERROR.

... progress throws error to the screen and finish

IF NOT result OR ERROR-STATUS:ERROR OR bufferTable :ERROR THEN DO:
... something ...
END.

... thesame sytuation with BUFFER-RELEASE().

Why NO-ERROR don't work here ?
what should J do?

THANKS!
 
I noticed this too.
In my case it was with buffer-release statement.

I solved this by using something like this:

Code:
define variable lReleaseOK as logical no-undo.
define variable hBuffer as handle no-undo.
 
create buffer hBuffer for table "customer".
 
do transaction:
 
if retry then do:
     if not lReleaseOk
     then do:
          message 'mycustommessage' return-value view-as alert-box.
          leave verwerk.
     end.
/*     else if not lValidateOk then do:  ..... end.  */
end.
 
hBuffer:buffer-create().
 
hBuffer::name = "John Doe".
 
lReleaseOK = hBuffer:buffer-release().
 
end. /* transaction */
 
/* cleanup */
delete object hBuffer.
 
assign hBuffer = ?.

The variable lReleaseOK is set with the buffer-release method and if the trigger returns an error, the error-condition is raised.
This is done on some other way then with static programming because the error doesn't seem to be caught by no-error.
So I suppose the no-error in this statement checks the error-status of the statement it self and not the error-status of the procedure called by the statement. This is handled by the return parameter of the message.
So, regardless of the no-error, the error condition is raised with the buffer-release method. And if the error condition is raised it jumps right back to the transaction block without processing any further statements. (Like any other statement without no-error).
So it seems like the error-condition is raised at an other level then you might expect looking at the code.

(I must admit this is just a theory :D ).

HTH,

Casper.
 
I use the following code to catch the error and suppress any output

Code:
      DEF VAR mOK AS LOG /* NO-UNDO*/.
      OUTPUT TO "errmsg.txt" KEEP-MESSAGES.
      DO ON ERROR  UNDO, LEAVE
         ON ENDKEY UNDO, LEAVE:
         vTable:BUFFER-RELEASE() NO-ERROR.
         mOk = YES.
      END.
      OUTPUT CLOSE.

HTH
 
Back
Top