(view source code of random.bat as plain text)
@ECHO OFF
REM Random.bat, Version 2.00 for DOS
REM Random number generator
REM Written by Rob van der Woude
REM http://www.robvanderwoude.com
REM Inspired by Tom Lavedas' "The Simple Way"
REM http://www.pressroom.com/~tglbatch/oldrandm.htm
REM Strip procedure by Laurence Soucy
REM http://bigfoot.com/~batfiles/
REM Recursion
IF "%1"=="Loop" GOTO Loop
IF "%1"=="Loop?" GOTO Loop
REM Store current time in environment variable
REM (adjust "TIME" string, parameter numbers
REM and ENTER.BAT file name for non-US/UK DOS)
VER | TIME | DATE | FIND /I "TIME" > TEMP.BAT
ECHO SET RND$=%%8>ENTER.BAT
ECHO IF NOT [%%9]==[] SET RND$=%%9>>ENTER.BAT
CALL TEMP.BAT
REM If decimal delimiter is "," then we're ready,
REM otherwise the variable needs to be "stripped"
ECHO %RND$% | FIND "." >NUL
IF NOT ERRORLEVEL 1 GOTO Strip
ECHO %RND$% | FIND "," >NUL
IF NOT ERRORLEVEL 1 GOTO Strip
ECHO %RND$% | FIND ":" >NUL
IF NOT ERRORLEVEL 1 GOTO Strip
ECHO %RND$% | FIND ";" >NUL
IF NOT ERRORLEVEL 1 GOTO Strip
ECHO %RND$% | FIND "-" >NUL
IF NOT ERRORLEVEL 1 GOTO Strip
ECHO %RND$% | FIND "/" >NUL
IF NOT ERRORLEVEL 1 GOTO Strip
SET RND=%RND$%
GOTO Display
:Strip
REM Strip variable and use only the part after the
REM last delimiter; main routine
ECHO ]|CHOICE /C:;%RND$%;]; %0 Loop >TEMP2.BAT
CALL TEMP2.BAT
:Display
REM Show the result
ECHO Random number is: %RND%
REM Clean up the mess
FOR %%A IN (TEMP TEMP2 ENTER) DO IF EXIST %%A.BAT DEL %%A.BAT
SET RND$=
GOTO End
:Loop
REM Strip variable and use only the part after the
REM last delimiter; recursively called subroutine
SHIFT
IF "%1"==";" GOTO Loop
IF "%1"=="]" GOTO End
IF "%1"=="]?]" GOTO End
IF "%1"=="[" GOTO Loop
IF "%1"=="." SET RND=
IF "%1"=="." GOTO Loop
IF "%1"==":" SET RND=
IF "%1"==":" GOTO Loop
SET RND=%RND%%1
GOTO Loop
:End
page last modified: 2024-04-16; loaded in 0.0084 seconds