Here's another bat file so you can test a bunch of values. It's just two lines long, and passes its command line option to the ERRLEV program, then prints the value of %ERRORLEVEL%
errlev %1 echo %ERRORLEVEL% (I called this program ERRLEVL.BAT) And you can use a FOR loop on the command line to test different values: for %n in (1 10 100 200 250 255) do call errlevl.bat %n D:\SRC>call errlevl.bat 1 D:\SRC>errlev 1 D:\SRC>echo 1 1 D:\SRC>call errlevl.bat 10 D:\SRC>errlev 10 D:\SRC>echo 10 10 D:\SRC>call errlevl.bat 100 D:\SRC>errlev 100 D:\SRC>echo 100 100 D:\SRC>call errlevl.bat 200 D:\SRC>errlev 200 D:\SRC>echo 200 200 D:\SRC>call errlevl.bat 250 D:\SRC>errlev 250 D:\SRC>echo 250 250 D:\SRC>call errlevl.bat 255 D:\SRC>errlev 255 D:\SRC>echo 255 255 If you try it for values above 255 (not valid on DOS, you can only have error levels up to 255) you'll see the returned int is truncated: for %n in (255 256 257 510 511 512) do call errlevl.bat %n D:\SRC>call errlevl.bat 255 D:\SRC>errlev 255 D:\SRC>echo 255 255 D:\SRC>call errlevl.bat 256 D:\SRC>errlev 256 D:\SRC>echo 0 0 D:\SRC>call errlevl.bat 257 D:\SRC>errlev 257 D:\SRC>echo 1 1 D:\SRC>call errlevl.bat 510 D:\SRC>errlev 510 D:\SRC>echo 254 254 D:\SRC>call errlevl.bat 511 D:\SRC>errlev 511 D:\SRC>echo 255 255 D:\SRC>call errlevl.bat 512 D:\SRC>errlev 512 D:\SRC>echo 0 0 *Remember, 255 is binary 1111 1111 256 is binary 1 0000 0000 257 is binary 1 0000 0001 ..and so on (That is, the error level can only be one byte long.) On Tue, Jun 9, 2026 at 6:42 PM Jim Hall <[email protected]> wrote: > > On Tue, Jun 9, 2026 at 3:48 PM victoria crenshaw wrote: > > > [..] > > > > a note for Jerome: > > The error levels is what i am going to focus next but i need to be in a > > voice chat with you or someone and discuss the error levels for the program > > > > because i never actually implemented error levels in any program before. > > so this is exciting > > > > i know where to implement them is in src/fdnpkg16.c > > with the QUIT(0) code lines > > > > Error levels are really easy: it's just whatever int the main() > program returns, and that gets returned to the operating system. For > DOS, use an error level that's greater than or equal to zero. (Zero > usually indicates success, some other value indicates an error or > warning.) > > Here's a sample program that just reads a single value from the > command line, and returns that int. (It returns zero otherwise.) > > > #include <stdio.h> > #include <stdlib.h> /* atoi */ > > int main(int argc, char **argv) > { > int errlevel; > > if (argc == 1) { return 0; } > > /* at least one command line argument. assume the first arg is an > integer, and use that for the error level. Should be greater than > or equal to zero. */ > > errlevel = atoi(argv[1]); > > if (errlevel<0) { return 0; } > > return errlevel; > } > > > > Save that as errlev.c then compile that and run it, you can generate > whatever error level you like. FreeDOS (actually FreeCOM) lets you > print the value using the %ERRORLEVEL% built-in environment variable, > so you can just echo %ERRORLEVEL% to see the value. > > Here's a simple bat that prints the values 1 to 5: (I called it errlevel.bat) > > errlev 1 > echo %errorlevel% > errlev 2 > echo %errorlevel% > errlev 3 > echo %errorlevel% > errlev 4 > echo %errorlevel% > errlev 5 > echo %errorlevel% > > > > This doesn't use @ECHO OFF so you can see everything that it's doing. > Here's a sample run: (I'm running this in my D:\SRC directory) > > D:\SRC>errlevel.bat > D:\SRC>errlev 1 > D:\SRC>echo 1 > 1 > D:\SRC>errlev 2 > D:\SRC>echo 2 > 2 > D:\SRC>errlev 3 > D:\SRC>echo 3 > 3 > D:\SRC>errlev 4 > D:\SRC>echo 4 > 4 > D:\SRC>errlev 5 > D:\SRC>echo 5 > 5 _______________________________________________ Freedos-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freedos-devel
