Hi!
The trick is that "if errorlevel 42" does not only trigger
if the errorlevel is EXACTLY 42, but if it is AT LEAST 42:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if
As you already found out, you could also use == for equality.
Of course, FreeCOM only supports a subset of what CMD does:
C:\>if /?
Performs conditional processing in batch programs.
IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command
NOT Specifies that the command shell should carry out the
command only if the condition is false.
ERRORLEVEL number Specifies a true condition if the last program run
returned an exit code equal to or greater than the
number specified.
command Specifies the command to carry out if the condition is
met.
string1==string2 Specifies a true condition if the specified text
strings match.
EXIST filename Specifies a true condition if the specified filename
exists.
C:\>
Here is a FreeCOM example after running an app which did
return the value 3 as errorlevel:
C:\>if %errorlevel%==4 echo yes
C:\>if %errorlevel%==3 echo yes
yes
C:\>if %errorlevel%==2 echo yes
C:\>if errorlevel 4 echo yes
C:\>if errorlevel 3 echo yes
yes
C:\>if errorlevel 2 echo yes
yes
C:\>echo %errorlevel%
3
Regards, Eric
_______________________________________________
Freedos-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-user