If Ü
ßßß
Performs conditional processing in a batch file. If the condition
specified in an IF command is true, FreeDOS carries out the command
that follows the condition. If it is false, FreeDOS ignores the
command.
Syntax: IF [not] errorlevel number command
IF [not] string1 == string2 command
IF [not] exist filename command
NOT Specifies that DOS 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
Notes
When a program stops, it returns an exit code to FreeDOS. The
errorlevel parameter lets you use exit codes as conditions.
Example:
The following batch program displays an error message if an error occurs
during formatting of the disk in drive A. If there is no error, the
error message is skipped:
:begin
echo off
format a: /s
if not errorlevel 1 goto end
echo An error occured during formatting.
:end
echo End of batch program