|
Answer» I couldn't find the right way to say this, but:
if %var%==(several variables here)
so like:
if %var%==a,b,c,d,e,F,g
I just don't know how you would put it.
Thanks.You can nest the if statements. 1. In Batch nested nIFs are used often. 2. You and use the AND operator. 3. You can aggregate results. (pseudo code) set got to zero if var is a bump got if var is b bump got if var is c bump got if got is 3 say 'got all' If got is 0 say 'got nada'
But I don't think that is what you want.
Do you want a CASE block? It is not native to batch files. (pseudo code) CASE BEGIN var = a goto isa var = b goto isb var = c goto isc END CASE
You would have more tools in a script language like Vb script. Code: [Select] Select Case testexpression [Case expressionlist-n [statements-n]] . . . [Case Else [elsestatements-n]] End Select I'm sort of new, but really I just want to be ABLE to have several possibilities on one "if" COMMAND.
I'm sorry if that doesn't make sense.
So like:
on "if %var%==1,2,3,4,5"
if either 1 through 5 is entered, it will execute a command
but is that the correct format for the command, or do I have to use an "and" command?
if so, Can I have some examples?
Thanks a bunch. AS has been said, batch does not have a multiple - If command, nor a CASE STATEMENT. You have to get crafty.
If a,b,c,d,e are consecutive numbers e.g. 1 to 5 then you can do this
if %var% GTR 0 ( if %var% LSS 6 ( goto pass ) ) echo Bad value! goto end
:pass echo Good value! :end
Otherwise you must test for the values individually
if "%var%"=="a" goto pass if "%var%"=="b" goto pass if "%var%"=="c" goto pass if "%var%"=="d" goto pass if "%var%"=="e" goto pass echo Bad value! goto end
:pass echo Good value! :end
Or you could use some FOR loop trickery but I won't put that here. Bill's around!
|