1.

Solve : random command?

Answer»

is there a way to make a random word from a list appear? like if i type a list of random nouns and then random VERBS, and a sentance with blanks where the words should go, i could FUNNY stuff lolz.You could do something with this:

:1
@echo off
set /a number="%random%" %%3 + 1 >nul
if /i %number%==1 echo Computer
if /i %number%==2 echo Hope
if /i %number%==3 echo Forums
pause
goto :1

I think it would get too complex though...yeah i could do that but i only need 2 LISTS of random words and how would i make the second?Quote

@echo off
set "list1=dude,programmer,geek,squarehead,cookie monster"
set "list2=eat,hug,destroy,unpimp,crack,hack,hammer"

call:rndselect a "%list1%"
call:rndselect b "%list2%"

echo.The %a% is going to %b% that SERVER. LOL!
pause
GOTO:EOF


:rndselect ret list -- RETURNS a rondomly selected string from a string list
:: -- ret [out] - valref for return value
:: -- list [in] - string list, comma separated
:$source http://www.dostips.com
SETLOCAL ENABLEDELAYEDEXPANSION
set "list=%~2"
set /a "n=0"
for /f "delims=" %%a in ('"echo.%list:,=&echo.%"') do (
set /a i+=1,r=!random! %% i
if !r! LSS 1 set "ret=%%a"
)
ENDLOCAL&IF "%~1" NEQ "" (SET %~1=%ret%) ELSE ECHO.%ret%
EXIT /b %ERRORLEVEL%

What'ya think gamerx365?
DOS IT HELP?

that one definetly works right. i am still working on figuring out how to make it so that I can make more than one random sentence but so that it has different words.If I understand what you mean, you just have to change this
Code: [Select]@echo off
set "list1=dude,programmer,geek,squarehead,cookie monster"
set "list2=eat,hug,destroy,unpimp,crack,hack,hammer"
[b]set "list3=one,two,three,four,five"[/b]

call:rndselect a "%list1%"
call:rndselect b "%list2%"
[b]call:rndselect c "%list3%"[/b]

echo.The %a% is going to %b% that server. LOL!
[b]echo. %c%[/b]
pause
GOTO:EOF

Very nice, DosItHelp.


Discussion

No Comment Found