3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Advanced Batch

Step 6IF Command - Everyone is Equal (1/2)

IF Command - Everyone is Equal (1/2)
«
  • cmd set variable1 if.JPG
  • notepad ifvariabletest.JPG
  • cmd ifvariabletest.JPG
That classic conditional operand. Basic, but powerful none-the-less.

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 executed
or 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 StepDownload PDFView All StepsNext Step »
1 comment
Jun 3, 2009. 1:50 PMGilrostwo says:
I just use...

if %%== goto

The blanks being variables and such.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
22
Followers
5
Author:Neodudeman