Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for max.bat

(view source code of max.bat as plain text)

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. IF "%~2"=="" GOTO Syntax
  4.  
  5. SETLOCAL ENABLEDELAYEDEXPANSION
  6. SET Max=%~1
  7. FOR %%A IN (%*) DO (
  8. 	ECHO.%%~A| FINDSTR /R /I /C:"[^0-9-]" >NUL
  9. 	IF NOT ERRORLEVEL 1 (
  10. 		ENDLOCAL
  11. 		GOTO Syntax
  12. 	)
  13. 	IF %%~A LSS !Max! SET /A Max = %%~A
  14. )
  15. ECHO.%Max%
  16. ENDLOCAL & SET Max=%Max%
  17. EXIT /B 0
  18.  
  19.  
  20. :Syntax
  21. ECHO.
  22. ECHO Max.bat,  Version 1.00 for Windows NT4+
  23. ECHO Returns the highest from a list of values on the command line
  24. ECHO.
  25. ECHO Usage:  MAX  num1  num2  [ num3  [ num4 ... ] ]
  26. ECHO.
  27. ECHO Notes:  The highest value is displayed on screen and stored in an environment
  28. ECHO         variable %%Max%%.
  29. ECHO         Works with (signed) integers only, size limited by OS version.
  30. ECHO.
  31. ECHO Written by Rob van der Woude
  32. ECHO http://www.robvanderwoude.com
  33.  
  34. IF "%OS%"=="Windows_NT" EXIT /B 1
  35.  

page last uploaded: 2017-08-21, 14:26