I have a list of about 50 names, I'm trying to print one at random, here is what I have so far.
set "names=Abel,Abelard,Ace,Adalee,Abilene,Riya,Bob,Harry,Phil,Dada,Mama,Dacey,Josh,Jo,Ben,Ada,Liam,Shane,Alan,Teddy,Dai,Dale,Dallas,Faber,Fabia,Faith,Faiza,Falco,Fabrice,Fabian,Haden,Hadwin,Hakeem,Mab,Mac,Mace,Macon,Mackland,Kapi,Noah,William,James,Logan,Benjamin,Mason,Oliver,Ethan,Daniel,Jayden"
set /a randomName=%random% %%50 +1
echo %randomName%
for /l %%i in (1; 1; 150) do call :sub %%i
goto end
:sub
for /f "tokens=%1 delims=," %%a in ("%names%") do (
if %%i == %randomName% (
echo Your random name is %%a
)
)
goto :eof
:end
echo If random number is over 31 it won't print a name
pause
It works, kinda, it prints the name but only if the random number is 31 or lower, if it's above it just skips the if and goes to the end.
Just wondering if anyone knows a way past this or is the limit for for and if commands 31?
Aucun commentaire:
Enregistrer un commentaire