Dec 112017
 
Displays ERRORLEVEL without having to go through long IF-THEN batch file routine. Checks internal COMMAND.COM flag location and reports. Comes with ASM source for the curious. Works only on DOS 3.1, 3.2, 3.3 and 4.0.
File CHECKELA.ZIP from The Programmer’s Corner in
Category Batch Files
Displays ERRORLEVEL without having to go through long IF-THEN batch file routine. Checks internal COMMAND.COM flag location and reports. Comes with ASM source for the curious. Works only on DOS 3.1, 3.2, 3.3 and 4.0.
File Name File Size Zip Size Zip Type
CHECKEL.ASM 6770 2518 deflated
CHECKEL.COM 829 560 deflated
CHECKEL.DOC 2386 1128 deflated

Download File CHECKELA.ZIP Here

Contents of the CHECKEL.DOC file


CHECKEL version 4.1 Glenn Snow

This program, CHECKEL, will allow you to find the current errorlevel
value from either the DOS prompt, or from within a batch file. I wrote
it to enable me to find the current errorlevel without going through the
endless wait for a long IF-THEN batch file. This current version works
only with DOS versions 3.1, 3.2, 3.3, and 4.0 (as far as I know) because those
are the only DOS versions I still own and therefore have access to.

The Assembly source code is provided for those who would like to see how it
works (no surprises at all). I used a couple of debuggers (and the
PC-Magazine utility called "RAMVIEW") to trace through COMMAND.COM and find
the address of the ERRORLEVEL flag, and then read this byte. I could find
no pointers to this flag at all, (also no surprise, since it is specifically
internal to each version of COMMAND.COM, and its batch file invocation
routine).

One improvement in this version (4.1) is that the errorlevel may be stored
(in a manner of speaking) into an environment variable. This is so that
you might delay whatever decision must be made to a later point in the
batch file. This is done by placing the name of the environment variable
you wish to use as "storage" after the CHECKEL command - thus:
CHECKEL ERR1
will check the current errorlevel, report it to the screen, and also save
the errorlevel as a STRING in the environment like so: ERR1=125 or whatever
the errorlevel was. Note, this is a STRING variable in the environment, since
the ENVIRONMENT is a collection of STRINGS, not numbers. If a secondary
command processor is running, only the TOPMOST errorlevel is stored in the
environment variable.

I only have tested out the environment variable stuff on DOS version 4.0, so
please let me know if it works on other versions.

If you make some improvements on this program, or have some suggestions, please
drop me a line and let me know. If I can do anything to make it more useful,
I'll be glad to do so, (assuming, of course, that I have a clue!)

Glenn Snow
999 East McKinley Avenue
Mundelein, IL 60060
(708) 566-4079 (voice)

or CompuServe 72317,2751


 December 11, 2017  Add comments

Leave a Reply