(view source code of reversent.bat as plain text)
@ECHO OFF
:: Keep variables local
SETLOCAL
:: Check command line parameters
IF [%1]==[] GOTO Syntax
ECHO.%* | FIND "=" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax
:: Initialize variables
SET REVERSE=
SET INPUT=%*
:: Strip leading space in NT 4 only
VER | FIND "Windows NT" >NUL
IF NOT ERRORLEVEL 1 SET INPUT=%INPUT:~1%
:Loop
:: Continue till the input string's last character
IF NOT DEFINED INPUT GOTO Finish
:: Separate first character from input string
SET FIRSTCHAR=%INPUT:~0,1%
SET INPUT=%INPUT:~1%
:: Rebuild string in reverse order
SET REVERSE=%FIRSTCHAR%%REVERSE%
:: Next character
GOTO Loop
:Finish
ECHO.
:: Add leading space for Windows 2000 and later
VER | FIND "Windows NT" >NUL
IF ERRORLEVEL 1 (ECHO Input string = %*) ELSE (ECHO Input string =%*)
ECHO Reverse string = %REVERSE%
GOTO End
:Syntax
ECHO.
ECHO REVERSE.BAT, Version 2.00 for Windows NT 4 / 2000
ECHO Reverses the input string specified on the command line
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
ECHO.
ECHO Usage: REVERSE ^<string^>
ECHO.
ECHO ^<string^> cannot contain equal signs ("=")
ECHO.
ECHO Example:
ECHO REVERSE Any string
ECHO.
ECHO returns:
ECHO Input string = Any string
ECHO Reverse string = gnirts ynA
:End
ENDLOCAL
page last modified: 2024-04-16; loaded in 0.0071 seconds