IBM Version 4 manual Appendix B. Original Examples in Additional BLanguages-187

Models: Version 4

1 505
Download 505 pages 30.92 Kb
Page 465
Image 465

C

exsr

error

C

eval

ReturnInt = close(FileDesc)

C

eval

ReturnInt = unlink(%ADDR(FileName))

C

eval

\INLR = '1'

C

return

 

C

else

 

C

eval

PrintLine = 'Close of link successful'

C

except

 

C

endif

 

C\

 

 

C\ Unlink test_file

 

 

C\

 

 

C

eval

ReturnInt = unlink(%ADDR(FileName))

C\

C\ Check for error and report status. If an error occurs,

C\ attempt cleanup.

 

 

C\

 

 

C

if

ReturnInt = -1

C

eval

PrintLine = 'Unlink of file failed'

C

exsr

error

C

eval

ReturnInt = unlink(%ADDR(FileName))

C

eval

\INLR = '1'

C

return

 

C

else

 

C

eval

PrintLine = 'Unlink of file successful'

C

except

 

C

endif

 

C\

 

 

C\ End of main program

 

C\

 

 

C

eval

PrintLine = 'Program run is successful'

C

except

 

C

eval

\INLR = '1'

C

return

 

C\

 

 

C\ Common error reporting subroutine C\

C\ If errors occur, the integrated file system exports the ￿variable C\ 'errno' to assist in determining the problem. As 'errno' is

C\ lowercase, ILE RPG cannot directly import this variable￿ and must C\ use a C module to access it. If the developer has ILE C

C\ available, the following sample C code will import 'errn￿o' and C\ make it available to the RPG application.

C\

C\

#include <errno.h>

C\

int geterrno()

C\

{

C\

return errno;

C\

}

C\

 

C\ To activate this C module, remove the four comment ident￿ifiers

C\ following the 'except' statement and remove the comment ￿identifier C\ from the errno prototype. Definitions for the returned errno

C\ are found in the file QSYSINC/SYS member ERRNO.

C\

 

 

 

C

error

begsr

 

C

 

except

 

C\

 

eval

ReturnInt = errno

Appendix B. Original Examples in Additional BLanguages-187

Page 465
Image 465
IBM Version 4 manual Appendix B. Original Examples in Additional BLanguages-187