Microsoft KB Archive/69442

COBOL 4.0 ANIM Compiler Directive Alters ERRORLEVEL Returned

PSS ID Number: Q69442 Article last modified on 04-20-1993

4.00 | 4.00 MS-DOS | OS/2

Summary: When errors occur during compilation, the COBOL 4.0 compiler returns a nonzero ERRORLEVEL to the MS-DOS or MS OS/2 operating system. You can detect the ERRORLEVEL when you invoke the compiler from within a batch or command file. However, when you add the ANIM directive to the compile line, the ERRORLEVEL always reads zero.

More Information: This technique of capturing the ERRORLEVEL is documented on page 3-11 of the “Microsoft COBOL 4.0: Operating Guide.” The batch file below compiles the program “PROG.CBL” with the ANIM directive. The resulting ERRORLEVEL is always zero even if errors are present. If the ANIM directive is removed, then the results will vary depending on whether or not errors are encountered. The following is an example of detecting ERRORLEVEL in an MS-DOS batch file:

COBOL prog.cbl ANIM; if ERRORLEVEL 1 goto nonzero if ERRORLEVEL 0 goto zero :nonzero echo COBOL Compile Results: ERRORS FOUND goto end :zero echo COBOL Compile Results: NO ERRORS FOUND goto end :end

Additional reference words: 4.00 Copyright Microsoft Corporation 1993.