elwayisgod
asked on
Set variable with 'OR' logic possible?
I need to set a variable based on two conditions. If either of the conditions are true then set the variable one way, if neither are true then set the variable another way.
Basically I'm playing with changing the 'theday' and the 'DATE_dow' variables and running. However it's not working. The logic is:
If %theday% LEQ 12 OR %DATE_dow% then excludeDirsDistr=Distr,Dis trstg,Dist rDEC,
else if neither of those are true then excludeDirsDistr=
I'm obviously not nesting this correctly or the logic above I can't accomplish like this. Played with all kinds of combinations and not working. Trying to avoid many 'IF' lines in order if possible...
Basically I'm playing with changing the 'theday' and the 'DATE_dow' variables and running. However it's not working. The logic is:
If %theday% LEQ 12 OR %DATE_dow% then excludeDirsDistr=Distr,Dis
else if neither of those are true then excludeDirsDistr=
I'm obviously not nesting this correctly or the logic above I can't accomplish like this. Played with all kinds of combinations and not working. Trying to avoid many 'IF' lines in order if possible...
set theday=11
set DATE_dow=Thu
set excludeDirsDistr=Distr,Distrstg,DistrDEC,
if not %theday% LEQ 12 if not %DATE_dow%==Wed set excludeDirsDistr=
I'd do it like this:
set theday=11
set DATE_dow=Thu
set excludeList=Distr,Distrstg,DistrDEC,
set excludeDirsDistr=
if %theday% LEQ 12 set excludeDirsDistr=%excludeList%
if /i %DATE_dow%==Wed set excludeDirsDistr=%excludeList%
ASKER
If %theday% LEQ to 12 then it needs to be empty. Above sets it to Distr,Distrstg,DistrDEC...
That's what you wanted in your question:
Anyway, whatever your goal is, the method remains the same if you want to combine several conditions with an "or":
1. You set the "false" as default value
2. You add one line per "true" condition where you set the "true" value.
If %theday% LEQ 12 OR %DATE_dow% then excludeDirsDistr=Distr,DisSo what is it exactly you want (especially the condition that's missing for "%DATE_dow%"?trstg,Dist rDEC,
Anyway, whatever your goal is, the method remains the same if you want to combine several conditions with an "or":
1. You set the "false" as default value
2. You add one line per "true" condition where you set the "true" value.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My bad had a typo:
If %theday% LEQ 12 OR %DATE_dow% ==Wed then excludeDirsDistr=Distr,Dis trstg,Dist rDEC,
else if neither of those are true then excludeDirsDistr=
Sorry about that. If I have to have multiple lines of IF then this will work as there are four different combinations. Just ugly.
If %theday% LEQ 12 OR %DATE_dow% ==Wed then excludeDirsDistr=Distr,Dis
else if neither of those are true then excludeDirsDistr=
Sorry about that. If I have to have multiple lines of IF then this will work as there are four different combinations. Just ugly.
set excludeDirsDistr=
if %theday% LEQ 12 if %DATE_dow%==Wed set excludeDirsDistr=
if %theday% LEQ 12 if not %DATE_dow%==Wed set excludeDirsDistr=
if not %theday% LEQ 12 if %DATE_dow%==Wed set excludeDirsDistr=
if not %theday% LEQ 12 if not %DATE_dow%==Wed set excludeDirsDistr=Distr,Distrstg,DistrDEC,
ASKER
@BP,
I think yours combines my 4 into two.... :)
I think yours combines my 4 into two.... :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Going with this as it covers all 4 possibilities:
set excludeDirsDistr=Distr,Distrstg,DistrDEC,
if %theday% LEQ 12 set excludeDirsDistr=
if %DATE_dow% EQU Wed set excludeDirsDistr=
ASKER
Thanks for clarification. I got caught up on the 'if not' and it threw me for loop :)
That is the exact opposite of
If %theday% LEQ 12 OR %DATE_dow% ==Wed then excludeDirsDistr=Distr,Distrstg,Dist rDEC,
ASKER
Open in new window