Computing.Net > Forums > Programming > batch response enforcing

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch response enforcing

Reply to Message Icon

Name: Ryan
Date: February 9, 2009 at 13:14:47 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: lee123abc
Date: February 9, 2009 at 15:17:28 Pacific
Reply:

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch response enforcing

Validate users response on XP batch www.computing.net/answers/programming/validate-users-response-on-xp-batch/13179.html

Ping Monitoring Batch File www.computing.net/answers/programming/ping-monitoring-batch-file/15405.html

Batch Coding - User input; response www.computing.net/answers/programming/batch-coding-user-input-response/13526.html