COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
file-number
is the Guardian or OSS file number. If the file is not open, file-number is 0.
If, after the file was opened, the I-O status code was “05,” rather than “00” (see Nonexistent
Files), file-number is -1.
error
is the last Guardian error number. If the file is an OSS file, error is 0.
Usage Consideration: Do not use COBOL_FILE_INFO_ to obtain the operating environment error
number associated with the failure of any input-output operation that is performed simply with
COBOL input-output verbs (such as READ). The HP COBOL special register GUARDIAN-ERR was
created for that purpose. Certain operations, such as a READ statement operating on the $RECEIVE
file, deliver meaningful values to GUARDIAN-ERR, but a call to COBOL_FILE_INFO_ would return
an inappropriate value of zero or an arbitrary, undefined value.
Non-Local Jumps in HP COBOL Applications
Sometimes an HP COBOL application may need to bypass the normal program call and return
mechanism to handle exceptions or errors encountered during execution. The standard HP C
functions setjmp() and longjmp() provide the functionality for non-local jumps but cannot be
called directly from HP COBOL programs using ENTER statements and have more restricted behavior
in mixed language applications. If a longjmp() call from an HP C function causes an active HP
COBOL program to be discarded, the next call to the same HP COBOL program will not work as
expected because the context information maintained by HP COBOL is not restored by the
longjmp() call.
The cobsetjmp.h (cobsetjh in the Guardian environment) header file defines the cobsetjmp()
macro and declares the coblongjmp() function and cobjmp_buf structure for non-local jumps
in mixed language HP COBOL programs.
cobsetjmp() and coblongjmp() can be called only from HP C functions, but unlike setjmp()
and longjmp(), cobsetjmp() and coblongjmp() can be safely used in mixed language
applications. All other restrictions on the use of setjmp() and longjmp() apply to cobsetjmp()
and coblongjmp() also. In particular, if a C function uses cobsetjmp() and then subsequently
returns to its caller, you cannot later use coblongjmp() with the buffer that was passed to
cobsetjmp().
Applications that use cobsetjmp() and coblongjmp() must be linked with ZCOBDLL.
cobsetjmp macro
NAME
cobsetjmp() — saves the current execution context in mixed language applications
SYNOPSIS
#include <cobsetjmp.h>
int cobsetjmp (struct cobjmp_buf *buf);
LIBRARY
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCOBDLL
H-series and J-series OSS processes: /G/system/zdllnnn/zcobdll
PARAMETERS
buf
Specifies a buffer in which the current execution environment is saved. The results of calling
the coblongjmp() function are undefined if the caller changes the contents of buf.
DESCRIPTION
652 Libraries and Utility Routines










