Created On:  24 January 2012

Problem:

When running the Net Express projmake utility from a batch file the errorlevel check is not failing when a program error is encountered.

Using the following in the batch file:

projmake -buildall testproj.app
if errorlevel 1 goto errors
goto end
:errors
echo "Error encountered"
:end
echo "Done"

Why, when an error occurs it is not branching to errors label?

Resolution:

The problem is that the projmake utility does not set the errorlevel directly based on if an error occurs somewhere in the build. Instead projmake just runs the cobol and cbllink utilities individually for each program in the project.

If an error is encountered on the compile of the first program then cobol will set the errorlevel accordingly by moving the return code into a register.

If this is the only program being compiled or it is the last one being compiled then it will seem like the errorlevel is being reported correctly beause the errorlevel will still be set but if another program is then compiled successfully then the errorlevel will be overwritten by the good result and the errorlevel test will be successful.

If you need this per program level of checking for the errorlevel then you need to create a batch file that calls cobol or cbllink directly for each program and then checks the errorlevel after each one.
Incident #2555201