Kbase 14066: How to return ERROR or STATUS to 4GL from C ( HLC )
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to return ERROR or STATUS to 4GL from C ( HLC )
How to return errors/status in HLI/C
------------------------------------
In both version 6 and version 7 of HLI/C, error handling
can be done in one of two ways. You can rely on Progress
default error handling or you can pass back errors/status
in shared variables from the C routine to the 4gl and
handle the error programatically in the 4gl.
Progress default error handling
-------------------------------
If you return from your C routine with a non-zero
return code, then the PRODSP() returns a long data
type value to PROGRESS. This is not a value that you
can check in the 4gl and act upon. THis value is
intercepted by PROGRESS and PROGRESS will raise the
error condition and default error handling will be
invoked. In other words, if you call a C routine
from the 4gl inside of a block that has specific
error properties then those error properties will
be invoked. In the following example, if an error is
returned from 'croutine' then the MESSAGE statement
following the CALL statement will NOT be invoked.
Progress default error handling will kick in and
an UNDO, RETRY of the whole block will be done.
FOR EACH customer ON ERROR UNDO, RETRY:
CALL croutine.
message "after croutine".
end.
Shared Variables
----------------
This method gives you, the programmer, more control
over error handling. You define a shared variable in
the 4gl program that will hold the error code. Within your
C function, set the shared variable with an HLC library
function before returning to PROGRESS. For example,
the following 4GL code defines errcode as a shared variable
and checks it after the call to the C routine:
def new shared var errcode as int.
call TESTPROC.
if errcode = 3 then message "error".
else message "errcode = " errcode.
The corresponding C routine would look like this:
int testproc()
{
int i;
/* places the 3 into the shared variable errcode */
/* so that errcode can be evaluated and acted upon in the 4gl */
i = prowti("errcode",0,3L,0);
return 0;
}
Written References:
Version 7 Progress Programming Handbook Ch 4
Version 7 External Program Interfaces section 6.4.2 and 6.8.7
Progress Software Technical Support Note # 14066