|
Answer» Hi all,
Is it possible to write an IF/OR STATEMENT ?
Like ... Code: [Select][highlight]IF [condition#1] OR [condition#2][/highlight] ( blah.. blah.. ) ELSE ( blah.. blah.. )Unable to find anything that says I can't, but can't find any examples if it is possible.
Cheers, /meDoesn't EXIST the operator OR for the sentence IF. You can emulate it executing several IF, one after the other
Code: [Select]@echo off set x=1 set y=0
set result=false if %x% EQU 0 set result=true if %y% EQU 0 set result=true
IF %result% EQU true ( echo x OR y are 0 ) ELSE ( echo x OR y are DISTINCT 0 )
Cheers [smiley=beer.gif]Many thanks Carlos, hadn't considered doing that.Sorry Carlos,
Just to confirm, the following would satisfy ensureing either BOS or CRM were ENTERED as a %Product% ... Code: [Select]set ProdResult=false if /i "%Product%" EQU "BOS" set ProdResult=true if /i "%Product%" EQU "CRM" set ProdResult=true
IF %result% EQU true (
if /i "%Product%" EQU "BOS" set Product=BOS if /i "%Product%" EQU "CRM" set Product=CRM
) ELSE (
@echo. @echo ERROR: Invalid Product Entered. echo Valid Products Are: @echo BOS - Back Office System @echo CRM - Customer Relationship Manager
goto :FinishRun
) Yes, this work fine, You are guaranteed that the input is BOS or CRM in capital letters.
|