Technical Notes Database TN834D.txt RETURNING ERROR LEVELS TO BATCH FILES Category :Pascal Platform :All Product :Turbo Pascal 4.0+ Description: Q. How do I set the error level within a Turbo Pascal program and test for the error level inside a batch (.BAT) file? A. The DOS error level can only be checked in a .BAT file and only a line immediately following the application that is returning the DOS error level. For example, suppose in the program TEST we set the error level to 5. Begin HALT(5); End. Then in a .BAT file we could have TEST IF ERROR LEVEL go do something ... The IF ERROR LEVEL 4 will evaluate to true because 5 is greater than 4 and the "go do something..." part will be executed. Note that you must always check the highest possible error level first. The expression IF ERROR LEVEL 0 will ALWAYS evaluate to true. Reference: 7/16/98 4:35:36 PM
Last Modified: 01-SEP-99