There is an example like this in the help:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)
It won't display anything. The explanation in the help says this:
The message will not be displayed, because when the first IF statement is read, the %VAR% in BOTH IF statements
is replaced; the reason is: it is within the body of the IF, and IF is a
compound statement. So, the IF inside the compound statement is actually comparing "before" and
"after", and those two can never be equal.
I don't really understand what that means. Could the experts explain it again?
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If you see this, it worked
)
It won't display anything. The explanation in the help says this:
The message will not be displayed, because when the first IF statement is read, the %VAR% in BOTH IF statements
is replaced; the reason is: it is within the body of the IF, and IF is a
compound statement. So, the IF inside the compound statement is actually comparing "before" and
"after", and those two can never be equal.
I don't really understand what that means. Could the experts explain it again?
