Page 1 of 1

IF command use logical operators....

Posted: 08 Mar 2011 13:40
by atamo
Hy

I've two conditions cond1 and cond2 , if both conditions are true do command1 if someone is false do command2.
is any chance to introduce these two conditions in "if" command using logical operators :?:
for now use this solution, but seems too long .....

if cond1 (
if cond2 (
command1) else (
command2)
) else command2

Re: IF command use logical operators....

Posted: 08 Mar 2011 13:56
by aGerman
No, there are no logical operators.
You could use something like this forlogical AND

Code: Select all

set /a n=0
if cond1 set /a n+=1
if cond2 set /a n+=1
if cond3 set /a n+=1
if %n%==3 (command1) else command2

and this for logical OR

Code: Select all

set /a n=0
if cond1 set /a n+=1
if cond2 set /a n+=1
if cond3 set /a n+=1
if %n% gtr 0 (command1) else command2


Regards
aGerman

Re: IF command use logical operators....

Posted: 08 Mar 2011 14:23
by atamo
nice catch

:lol: :P :lol:

thank you very much.