Let us call %1 as variable1
So here in this statement the script means
If contents of variable1 begins with Sub then goto.
In this example it is used as a regular expression to indicate
' whatever after wards '
2007-09-19 21:36:26
·
answer #1
·
answered by Andy 3
·
1⤊
5⤋
Typically, extra characters are put into expressions like this to prevent an error condition when a variable is empty, null, or not provided.
For instance, if the test expression was used without the period, then it would look like this,
if %1==Sub goto %2
and you ran your batch file without providing a value for %1, then the null value of %1 will translate into a line like this,
if ==Sub goto %2
and you would get an error like, "==Sub was unexpected at this time." Because the "if" expression isn't properly defined.
So, by putting a default placeholder around the variable, this prevents the error condition. If %1 is left empty in your original line, then the expression becomes
if .==Sub. goto %2
And the "if" line can be understood by the batch file because there is something on both sides of the test.
Usually, I use quotes around my variable tests, like
If "%1"=="Sub" goto %2
or, to test for blank or null values, like this
If "%1"=="" goto :Syntax
and I've have a :SYNTAX section to explain how to run the batch file with proper inputs, but that's just a preference. Periods do the same thing.
2007-09-22 02:23:20
·
answer #2
·
answered by Kevin 7
·
3⤊
0⤋