I am trying to write a batch script to get a string in a variable and check if it is empty, and if it is empty then it is directed to a loop. The below code represents the problem
:loop
set /p cide=
IF NOT "a%1"=="a" (set cide="%1")
IF [%1]==[] goto loop
ELSE
echo IDE entered
TIMEOUT 5 > NUL
The program starts to loop again even if i give a string.
I tried to put IF [%cide%]==[] goto loop
or IF %cide%==[] goto loop
it gave an error stating "ELSE" not recognized.
Any help is appreciated. Thanks
You can try something like that :
@echo off
:loop
cls & Color 0A
echo Type what you want !
set /p "cide="
IF "%cide%"=="" (
Cls & Color 0C
echo You must enter something
Timeout /T 2 /NoBreak>nul
goto loop
) ELSE (
Goto Next
)
:Next
Cls
echo %cide% is entered
pause
@echo off
:loop
cls & Color 0A
echo Type what you want !
set /p "cide="
IF [%cide%]==[] (
Cls & Color 0C
echo You must enter something
choice /d y /t 2 > nul
goto loop
) ELSE (
Goto Next
)
:Next
Cls
echo %cide% is entered
pause
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With