OR operation in IF command

G

Guest

I need a command line syntax for multiple OR operations in a single IF
command. As below:
IF A=2 OR 3 OR 7 OR 11 OR 12
SET HHMM=GROUP1
GOTO %HHMM%:
 
P

Phil Robyn

Galop said:
I need a command line syntax for multiple OR operations in a single IF
command. As below:
IF A=2 OR 3 OR 7 OR 11 OR 12
SET HHMM=GROUP1
GOTO %HHMM%:

- - - - - - begin screen capture WinXP SP2 - - - - - -
C:\cmd>demo\MultipleOR 12
The value of A - 12 - is one of the following: 2 3 7 11 12

C:\cmd>demo\MultipleOR ab
The value of A - ab - is *not* one of the following: 2 3 7 11 12

C:\cmd>demo\MultipleOR 3
The value of A - 3 - is one of the following: 2 3 7 11 12

C:\cmd>demo\MultipleOR 3.3.
The value of A - 3.3. - is *not* one of the following: 2 3 7 11 12

C:\cmd>demo\MultipleOR 7
The value of A - 7 - is one of the following: 2 3 7 11 12

C:\cmd>wyllist demo\MultipleOR.cmd
==========begin file C:\cmd\demo\MultipleOR.cmd ==========
001. @echo off
002. setlocal
003. set A=%1
004. echo/.2.3.7.11.12. | findstr /c:".%A%." > nul
005. if %errorlevel% equ 0 (
006. echo/The value of A - %A% - is one of the^
007. following: 2 3 7 11 12
008. ) else (
009. echo/The value of A - %A% - is *not* one of^
010. the following: 2 3 7 11 12
011. )
==========end file C:\cmd\demo\MultipleOR.cmd ==========
- - - - - - end screen capture WinXP SP2 - - - - - -
 
T

Todd Vargo

Galop said:
I need a command line syntax for multiple OR operations in a single IF
command. As below:
IF A=2 OR 3 OR 7 OR 11 OR 12
SET HHMM=GROUP1
GOTO %HHMM%:

Does this help?

set a=2
for %%? in (2 3 7 11 12) do if %a%==%%? goto GROUP1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top