Computing.Net > Forums > Disk Operating System > probability batch programs

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.

probability batch programs

Reply to Message Icon

Name: Jeremy
Date: February 28, 2001 at 18:56:57 Pacific
Comment:

Hey all, I have very little computer knowledge. I'm trying to write a batch program that will pick a random number between 0 and 1. If the number is between 0 and .2, i want the batch program to run one set of commands, if not, a different set. I'm sure this can be done, it's probably QUITE simple. But i dunno how -- so can someone tell me? Pleeeeeeease? (E-mail would be the best way to answer, but I'll check here too).

THANKS!
-Jeremy



Sponsored Link
Ads by Google

Response Number 1
Name: Michael
Date: March 1, 2001 at 07:27:32 Pacific
Reply:

Standard DOS batch does not support random number generation. In fact, it has no 'built-in' support for any type of arithmetic. You either need to either a) find a 3rd party piece of software that will generate a random number and pass the value to an environmental variable or b) write a program yourself to do it. Qbasic is probably the easiest way.

-Michael


0

Response Number 2
Name: World Library
Date: March 1, 2001 at 08:10:03 Pacific
Reply:

Perhaps this will help.

http://www.calweb.com/~webspace/batch/samples/addition.txt


0

Response Number 3
Name: Laurence
Date: March 1, 2001 at 10:42:35 Pacific
Reply:

This batch will not give you technically
random numbers, but random for most practical purposes.

:: random#.bat
@ECHO off
IF "%1"=="ReCuRs" GOTO recurs
IF "%1"=="[" GOTO recurs2
ECHO @PROMPT SET nbr=$t> %temp%.\tim1.bat
%COMSPEC% /e:2048 /c %temp%.\tim1.bat> %temp%.\tim2.bat
CALL %temp%.\tim2.bat
CALL %0 ReCuRs %nbr%
ECHO random two digit number is %nbr%
ECHO ; |CHOICE.COM /C;%nbr%; %0;>%temp%.\parse1.bat
%temp%.\parse1.bat

:recurs
:recurs2
SET nbr=%3
IF "%1"=="[" ECHO random single digit number is %nbr%
IF exist %temp%.\tim?.bat DEL %temp%.\tim?.bat
IF exist %temp%.\parse1.bat DEL %temp%.\parse1.bat
:end


Batfiles: The DOS batch file programming handbook


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Cannot type characters wi... ping stat.



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: probability batch programs

backup batch program www.computing.net/answers/dos/backup-batch-program/2354.html

Telnet through batch program. Urgent!!! www.computing.net/answers/dos/telnet-through-batch-program-urgent/10218.html

batch program to test disk space www.computing.net/answers/dos/batch-program-to-test-disk-space/14327.html