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
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).
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
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
Summary: I need help writing a bath program that will backup one directory to another. The batch program needs two take two parameters and only two parameters, a source and destination. Once the parameters are...
Summary: Hi all, I want to automatically open a telnet session through a batch script. The user name and password should also be automatically supplied by the batch script. After opening the telnet session it ...
Summary: Hi, I have a batch program that copies a backup file everyday to a cdr. I need to include in the batch file code that checks to see if there is enough space left on the disk for the backup file being ...