(view source code of chomp.bat as plain text)
@ECHO OFF
:: Command line check
IF "%1"=="" GOTO Syntax
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
:: Keep variables local
SETLOCAL
:: Strip leading space added by Windows NT 4
SET STRING=%*
VER | FIND "Windows NT" >NUL
IF NOT ERRORLEVEL 1 SET STRING=%STRING:~1%
:: Create temporary Kix script
:: (Kix displays strings without carriage returns by default)
(ECHO $RC=REDIRECTOUTPUT^("%%TEMP%%.\CHOMP.DAT"^)) > %TEMP%.\CHOMP.KIX
(ECHO."%STRING%") >> %TEMP%.\CHOMP.KIX
(ECHO $RC=REDIRECTOUTPUT^(""^)) >> %TEMP%.\CHOMP.KIX
:: Call the temporary Kix script
KIX32 %TEMP%.\CHOMP.KIX
:: Display the temporary file created by the temporary Kix script
TYPE %TEMP%.\CHOMP.DAT
:: Delete the temporary files
DEL %TEMP%.\CHOMP.KIX
DEL %TEMP%.\CHOMP.DAT
:: Done
ENDLOCAL
GOTO:EOF
:Syntax
(ECHO.) 1>&2
(ECHO Chomp.bat, Version 1.01 for Windows NT 4/2000) 1>&2
(ECHO Displays command line parameters on screen) 1>&2
(ECHO ^(on StdOut^) without a carriage return.) 1>&2
(ECHO.) 1>&2
(ECHO Usage: %~n0 ^<string^>) 1>&2
(ECHO.) 1>&2
(ECHO Output: ^<string^> without carriage return on StdOut) 1>&2
(ECHO.) 1>&2
(ECHO Remarks: [1] ^<string^> should NOT contain any double quotes!) 1>&2
(ECHO [2] Windows 2000 will strip leading spaces from ^<string^>) 1>&2
(ECHO [3] This batch file uses Kix, make sure it is installed) 1>&2
(ECHO and that KIX32.EXE can be found in the PATH) 1>&2
(ECHO.) 1>&2
(ECHO Example: ^> SETDATE.BAT ECHO @ECHO OFF) 1>&2
(ECHO ^>^>SETDATE.BAT CALL %~nx0 SET DATE=) 1>&2
(ECHO ^>^>SETDATE.BAT DATE/T) 1>&2
(ECHO CALL SETDATE.BAT) 1>&2
(ECHO SET DATE) 1>&2
(ECHO will display:) 1>&2
FOR /F "tokens=*" %%A IN ('DATE/T') DO (ECHO DATE=%%A) 1>&2
(ECHO.) 1>&2
(ECHO Written by Rob van der Woude) 1>&2
(ECHO http://www.robvanderwoude.com) 1>&2
page last modified: 2024-04-16; loaded in 0.0073 seconds