Called If Statement Not Functioning?

November 23, 2011 at 09:04:54
Specs: Windows Vista
Once my coding gets to :CheckInput02, it gets all messed up...

:SetError
:: Sets Error to 0
:: ! - ERROR 1 = +1
:: \ - ERROR 2 = +2
:: / - ERROR 3 = +4
:: ERROR 4 = +8
:: ERROR 5 = +16
:: ERROR 6 = +32
:: ERROR 7 = +64
:: ERROR 8 = +256
:: ERROR 9 = +512
set Error=="0"
set input=="This is a test with ! and /"
goto GetTemp

:GetTemp
echo. 2>C:\temp\MCinfo.dat
ECHO %input%>>C:\temp\MCinfo.dat
goto GetResult

:GetResult
call :CheckInput01
echo %error%
call :CheckInput02
echo %error%
call :CheckInput03
echo %error%
::call :CheckInput04
::call :CheckInput05
::call :CheckInput06
::call :CheckInput07
::call :CheckInput08
::call :CheckInput09
if "%error%"=="1" (
echo\
echo You can't have '!' in your text!
goto GetText
) else (
if "%error%"=="2" (
echo\
echo You can't have '\' in your text!
goto GetText
) else (
if "%error%"=="4" (
echo\
echo You can't have '/' in your text!
goto GetText
) else (
if "%error%"=="3" (
echo\
echo You can't have '! \' in your text!
goto GetText
) else (
if "%error%"=="5" (
echo\
echo You can't have '! /' in your text!
goto GetText
) else (
if "%error%"=="6" (
echo\
echo You can't have '\ /' in your text!
goto GetText
) else (
if "%error%"=="0" (
goto GetRan
)
)
)
)
)
)
)

:CheckInput01
findstr /I /L /M "!" "C:\temp\MCinfo.dat"
If "%errorlevel%"=="0" (
set /a error+=1
goto :eof
) else (
If "%errorlevel%"=="1" (
goto :eof
)
)

:CheckInput02
findstr /I /L /M "\" "C:\temp\MCinfo.dat"
If "%errorlevel%"=="0" (
set /a error+=2
goto :eof
) else (
If "%errorlevel%"=="1" (
goto :eof
)
)

:CheckInput03
findstr /I /L /M "\" "C:\temp\MCinfo.dat"
If "%errorlevel%"=="0" (
set /a error+=4
goto :eof
) else (
If "%errorlevel%"=="1" (
goto :eof
)
)

:GetText
Pause

:GetRen
echo SUCESS
Pause


See More: Called If Statement Not Functioning?

Report •


#1
November 24, 2011 at 11:09:20
I keep seeing the same mistakes in your code. I suggest you keep echo on and see exactly how your lines are being parsed.

How To Ask Questions The Smart Way


Report •

#2
November 26, 2011 at 07:15:44
I doubled up the \ and it worked, but the / doesn't work when I double that. =\

Report •
Related Solutions


Ask Question