Using OR in and IF statement [duplicate]
Can I use OR in an IF statement? Something like this:
if %str% equ 1 **OR** %str% equ 2 echo %str%
No, you cannot. You can do this with a goto
:
if %str% equ 1 goto dosomething
if %str% equ 2 goto dosomething
goto aftersomething
:dosomething
rem do something
:aftersomething
Or with a temporary variable:
set var=
if %str% equ 1 set var=1
if %str% equ 2 set var=1
if defined var (
rem do something
)
精彩评论