I need a batch file that will generate a specific "random" number.
I dont know how to code this, obviously so Ill make up my own coding language to explain.:start
x = choose_random(0,00)
y = choose_random(3,5,7,8,10,12)
echo %x%%y%%x%%y%%x%%y%%x%%y%%x%%y%
pause:
goto startan example output could be: 0080070507005
@echo off & setlocal enabledelayedexpansion
set n= 3 5 7 81012
:loop
set /a r1=%random%"%%"6*2
set z=!n:~%r1%,2!
set z=%z: =%
set /a c=%random% "%%" 2
if %c% equ 1 set c=00
echo %c%%z%
:: does it look right?
pause
goto :loop
Almost... so close. Instead of it generating like a supposed 007 then having to click enter to generate a new one, Id like it to echo 5 sets. so when I changed your code to: "echo %c%%z%%c%%z%%c%%z%%c%%z%%c%%z%" near the end to make 5 sets, it just displays 007007007007007.
I need it too be more like 05007080305
@echo off & setlocal enabledelayedexpansion
set n= 3 5 7 81012
set out=
:loop
set /a r1=%random%"%%"6*2
set z=!n:~%r1%,2!
set z=%z: =%
set /a c=%random% "%%" 2
if %c% equ 1 set c=00
set /a I+=1
if !I! equ 6 (
echo !out!
set out=
set I=0
) else (
set out=!out!%c%%z%*
)
pause
goto :loop
::===== end
the asterisk is just for debugging (since it is hard to tell how many items were actually delivered). Remove it when things look right.
PERFECT! Works like a charm.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |