0

I'd like to know if everything is fine since I have the value "H1" not working in this set

set /p LL1=
IF "%LL1%" == "1" (
    goto :LL1
) ELSE (
    IF "%LL1%" == "EN" (
        goto :LL1
    ) ELSE (
    goto :LLERR
        IF "%LL1%" == "H1" (
            goto :LLH
        ) ELSE (
            IF "%LL1%" == " " (
                goto :LLERR
            ) ELSE (
                IF "%LL1%" == "" (
                    goto :LLERR
                ) ELSE (
                goto :LLERR
                )
            )
        )
    )
)

1 / EN input works, H1 doesn't and space / void is blocked as intended , I am really lost on this one , got any idea ?

Thanks in advance.

MicHeK
  • 1
  • 1

2 Answers2

2

This is the "standard" way to do it:

set /p LL1=

IF "%LL1%" == "1"  goto :LL1
IF "%LL1%" == "EN" goto :LL1
IF "%LL1%" == "H1" goto :LLH
goto :LLERR

However, I would do it this way:

set /p LL1=

rem Call the given label, hide error message
call :Label-%LL1%  2> NUL
if errorlevel 1 goto :LLERR

echo Subroutine called OK
goto :EOF

:Label-1
:Label-EN
echo This is LL1
exit /B

:Label-H1
echo This is LLH
exit /B

Or, better yet, using a choice comand instead set /p

Aacini
  • 65,180
  • 12
  • 72
  • 108
-2
set /p LL1=

IF "%LL1%" == "1" (
    goto :LL1
    IF "%LL1%" == "EN" (
        goto :LL1
        IF "%LL1%" == "H1" (
            goto :LLH
            IF "%LL1%" == " " (
                goto :LLERR
                IF "%LL1%" == "" (
                    goto :LLERR
                ) ELSE (
                goto :LLERR
                )
            )
        )
    )
)

Is it any better like this so ?

MicHeK
  • 1
  • 1