Nested Ifs Problem

November 23, 2011 at 06:48:25
Specs: Windows Vista
set ExclamationMark=="!"
set Star=="*"
set Error01=="YES"
set Error02=="YES"
if not "%input%"=="%ExclamationMark%" (
	set Error01=="NO"
if not "%input%"=="%Star%" (
	set Error02=="NO"
	goto GetRan
) else (
	if %Error01%=="YES" (
	set %Error01Stuff%=="You have error 1"
		if %Error02%=="YES" (
		set %Error02Stuff%=="You have error 2"
		echo %Error01Stuff% %Error02Stuff%
		goto GetText

My first time using if inside of if.
If the user inputs a star but not a exclamation mark, it should change the Error01 variable to NO and keep Error02 the same.Then it should set the ErrorXXStuff based on the ErrorXX variables and then echo the errors and go back to GetText again.

See More: Nested Ifs Problem

Report •

December 2, 2011 at 08:02:35
one closing bracket is missing
when reading through your code count the opening and closing brackets, +1 on open -1 on close, result should come to 0
use proper idention, this makes it easier to see which else belongs to which if

depending on programming language it might be required to have an else to every if when nesting is used, if there is nothing to do in an if or else case call a function that does nothing

Report •

December 2, 2011 at 16:26:39
Another tip: Does Vista Set command requires two = characters? See

Please come back & tell us if your problem is resolved.

Report •

Related Solutions

Ask Question