Skip to main content

Hi,

 

I'm using the NetExpress v3.1 and I had an entry callback in my program, as below;

 

000-Program-Body section.
     invoke entrycallback "new" using z"onCloudError"
                            returning osException
     invoke exceptmgr "register" using oleExceptMgr osException

           :
           :
           :

888-Callback section.
entry "onCloudError" using by reference lnkErrObject
                           by reference lnkErrNumber
                           by reference lnkErrText.

  ....{do some display} and..

  go to 000-Program-Body.

I need to go back to the top of my program, and just continue with the normal flow (again) and registering the callback (again)... is there any problem with the computer looping back without "cancelling" the callback before "registering" again??


#netexpress3.10
#cobolnetexpress

Hi,

 

I'm using the NetExpress v3.1 and I had an entry callback in my program, as below;

 

000-Program-Body section.
     invoke entrycallback "new" using z"onCloudError"
                            returning osException
     invoke exceptmgr "register" using oleExceptMgr osException

           :
           :
           :

888-Callback section.
entry "onCloudError" using by reference lnkErrObject
                           by reference lnkErrNumber
                           by reference lnkErrText.

  ....{do some display} and..

  go to 000-Program-Body.

I need to go back to the top of my program, and just continue with the normal flow (again) and registering the callback (again)... is there any problem with the computer looping back without "cancelling" the callback before "registering" again??


#netexpress3.10
#cobolnetexpress

If this is truly an exception handler that is trapping a COM exception then it is normally good practice to display an error and then terminate the program. If it is a non-fatal exception and you would like to continue then you really should return from the exception handler using an exit program or goback and then continue the program where you left off unwinding the stack to return to the beginning. Using a GO TO statement to exit one section and enter a new one can cause problems especially if there are any perform thru statements in the program. Creating a new callback and registering it as an exceptionhandler each time thru will cause a memory leak as there is no automatic garbage collection in native oo-code like there is in managed code.

I would recommend that you do something like the following: 

 
01 pic x value "N".
   88 com-error-occurred value "Y"
      when set to false "N".

000-Program-Body section
    perform 100-create-callback
    perform until exit
       set com-error-occurred to false
       perform 200-process-com
       if all-done
          exit perform
       end-if
    end-perform.

100-create-callback.

    invoke entrycallback "new" using z"onCloudError"
       returning osException
    invoke exceptmgr "register" using oleExceptMgr osException.

 200-process-com.

    invoke ...
    *> COM error could occur here
    if com-error-occurred
       exit paragraph
    end-if.

    *> when processing is complete 
    set all-done to true.

 888-Callback section.
    entry "onCloudError" using by reference lnkErrObject
       by reference lnkErrNumber
       by reference lnkErrText.

    ....{do some display} and..
    set com-error-occurred to true
    exit program.