I want to check if both sides of the equl sign are equal.
If not the "If" branch should be executed.
Should I use brackets or not?
if NOT ...==...
or
if NOT (... == ...)
In other words what has a higher priority == or NOT ?
Peter
What is better: if NOT ...==... or if NOT (... == ...) ?
Moderator: DosItHelp
Re: What is better: if NOT ...==... or if NOT (... == ...)
Hi pstein,
I would recommend the form
The "bracket" variant will always result to false
Because batch always make a string compare and the brackets haven't any special meaning there you would compare
(leftside with rightside) also the brackets are compared then.
hope it helps
jeb
I would recommend the form
Code: Select all
if NOT "%var1%"=="%var2%" ( echo true ) ELSE (echo false)
The "bracket" variant will always result to false

Because batch always make a string compare and the brackets haven't any special meaning there you would compare
(leftside with rightside) also the brackets are compared then.
hope it helps
jeb