zorvek (Kevin Jones)
asked on
Batch Nested IFs
Why does this not work?
SET X=1
IF %X% == 1 (
SET Y=2
IF %Y% == 2 (
SET Z=3
)
)
PAUSE
Kevin
SET X=1
IF %X% == 1 (
SET Y=2
IF %Y% == 2 (
SET Z=3
)
)
PAUSE
Kevin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In this case, just !y! needs changing. But it wouldn't hurt to change it all.
ASKER
That worked. But why? It appears that % confuses the parser when it is evaluating the IF.
Kevin
Kevin
IDK why. Maybe someone else can help there. Actually, it applies to any nesting capable command, not just for IF. This includes the FOR command.
ASKER
OK
Thank you!
Kevin
Thank you!
Kevin
You're welcome. Have a nice weekend.