Step 6IF Command - Everyone is Equal (1/2)
For those who have never programmed before, the IF command is exactly how it sounds. If an expression in the syntax proves true (or NOT true) then the very next sequence of commands will carry out.
The basic command line goes like this:
IF %variable1%==%variable2% ECHO This part is executedor if you have more than one syntax.
@ECHO OFFIF %variable1%==%variable2% (ECHO This part is executed.ECHO So is this.) ELSE (ECHO If variable1 doesn't = variable 2, this happens.ECHO and this happens too.)
Note: The peculiar placing of parenthesis is not because I don't believe in organized code, but because if they're not in those places, the whole IF snippet will not work. Thus, if there Is any error with your IF code, it's most likely because of the parenthesis.
To run this particular batch, I actually used the Command Prompt itself, so that I could set the variables without having to edit the IfVariableTest.bat multiple times.
| « Previous Step | Download PDFView All Steps | Next Step » |

















































if %%== goto
The blanks being variables and such.