IBM Version 4 Universal Remote User Manual


 
IF BYTES-READ = -1 MOVE "Read failed"
TO LIST-LINE,
PERFORM ERROR-FOUND,
ELSE IF BYTES-READ = BYTES-WRITTEN
MOVE BUFFER TO DATA-READ,
WRITE LIST-LINE FROM DATAIN,
ELSE MOVE "Data Truncation on Read"
TO LIST-LINE,
PERFORM ERROR-FOUND.
ᑍ Close test.file via file descriptor
CALL "close" USING BY VALUE FILE-DESCRIPTOR,
GIVING RETURN-INT.
ᑍ Check for error and report status.
IF RETURN-INT = -1 MOVE "Could not close file"
TO LIST-LINE,
PERFORM ERROR-FOUND,
ELSE MOVE "Successfully closed file"
TO LIST-LINE,
WRITE LIST-LINE.
ᑍ Unlink test.file
CALL "unlink" USING BY VALUE ADDRESS OF TESTFILE,
GIVING RETURN-INT.
ᑍ Check for error and report status.
IF RETURN-INT = -1 MOVE "Unlink of file failed"
TO LIST-LINE,
PERFORM ERROR-FOUND,
ELSE MOVE "Unlink of file successful"
TO LIST-LINE,
WRITE LIST-LINE.
MOVE "Program run is successful" TO LIST-LINE.
WRITE LIST-LINE.
STOP RUN.
ᑍ End of MAINLINE
ᑍ Common error reporting subroutine
ᑍ If errors occur, the Integrated File System exports the
ᑍ variable 'errno' to assist in determining the problem. As
ᑍ 'errno' is lowercase, ILE COBOL cannot directly import this
ᑍ variable and must use a C module to access it. If the
ᑍ developer has ILE C available, the following sample C code
ᑍ will import 'errno' and make it available to the COBOL
ᑍ application
#include <errno.h>
int geterrno()
{
B-182 System API Programming V4R1