batch response enforcing

Ryan February 9, 2009 at 13:14:47
Specs: Windows XP
I am writing a batch file that requires a
response of a number.
The numbers can range between 1-2000
I need the response to be forced to fit a naming convention.
For example, if you type 8, 08, 008, or 0008
as the response, i need the answer of 0008
returned.

See More: batch response enforcing

Report •


#1
February 9, 2009 at 15:17:28
Please let me know if this is what you are looking for...

::(to MANUALLY get number)
@echo off
:USER_RANDOM
cls & echo Please enter your number from 1 - 2000...
set /p num=
if %num% gtr 2000 echo The numbers range from 1 - 2000... & PING 1.1.1.1 -n 1 -w 2000>nul & goto :USER_RANDOM

if %num% lss 10 set num=000%num% & goto :CONTINUE
if %num% lss 100 set num=00%num% & goto :CONTINUE
if %num% lss 1000 set num=0%num% & goto :CONTINUE

:CONTINUE
echo %num%
pause>nul
::end of code

::++++++++++++++++++++++++++++++++++++++++
::(to AUTOMATICALLY get number)
@echo off
:MAKE_RANDOM
cls
set num=%random%
if %num% gtr 2000 goto :MAKE_RANDOM

if %num% lss 10 set num=000%num% & goto :CONTINUE
if %num% lss 100 set num=00%num% & goto :CONTINUE
if %num% lss 1000 set num=0%num% & goto :CONTINUE

:CONTINUE
echo %num%
pause>nul
::end of code


Report •
Related Solutions


Ask Question