Code: Select all
'(' was unexpected at this time
I understand why it does this, but I don't know how to make an IF statement pickup this null value and tell the user to type something.
Thanks
phillid
Moderator: DosItHelp
Code: Select all
'(' was unexpected at this time
Code: Select all
@echo off &setlocal
:: destoy the %input% in case you set any value before
set "input="
:: Wait for user input
set /p "input=Enter your value: "
:: variable input is "not defined" in case the user entered nothing
if not defined input (
echo you entered nothing
)
:: if you would use quotes, you get no error
if "%input%"=="xyz" (
echo you entered xyz
) else (
echo you entered NOT xyz
)
pause
Code: Select all
if "%input%"=="" echo Empty string entered.