1.

Solve : how do I disallow a null entry from a user??

Answer»

Here is what I have :


@ echo off
cd\
cls
:start
cls
Set Unit=
Echo For funding purposes, we NEED to know what Unit you are from
Set /P Unit=Please enter unit ID
if /i %Unit% EQU null goto start
Echo %Unit%, %computername%, %date%, %time% >>c:\test.txt
@ echo off
cd\
cls
:start
cls
Set Unit=
Echo For funding purposes, we need to know what Unit you are from
Set /P Unit=Please enter unit ID
if /i %Unit% EQU null goto start
if "%Unit%"=="" (
echo.
echo Please type something!
echo Please try again
echo.
goto start
)
Echo %Unit%, %computername%, %date%, %time% >>c:\test.txt


Does that work if a "return" or "enter" is pressed?Quote from: Aegis on April 07, 2009, 04:13:21 PM

Does that work if a "return" or "enter" is pressed?

It will ONLY work if Enter/Return is pressed. The set /p command requires either a string of characters terminated by Enter, or Enter alone. The "null string", represented by "", is another way of saying "Enter".
THANK you -- appreciate the explanation!That worked! Thanks for your help.


Discussion

No Comment Found