Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for num2oct.bat

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

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. IF      "%~1"==""           GOTO Syntax
  4. IF NOT  "%~2"==""           GOTO Syntax
  5.  
  6. SETLOCAL ENABLEDELAYEDEXPANSION
  7. SET /A Num = %~1
  8. SET Oct=
  9.  
  10. :Loop
  11. SET /A "OctTmp = Num %% 8"
  12. SET /A Num /= 8
  13. SET Oct=%OctTmp%%Oct%
  14. IF %Num% GTR 0 GOTO Loop
  15.  
  16. ECHO.%Oct%
  17.  
  18. ENDLOCAL
  19. GOTO:EOF
  20.  
  21.  
  22. :Syntax
  23. ECHO.
  24. ECHO Num2Oct.bat,  Version 1.01 for Windows NT4 and later
  25. ECHO Convert the specified number to octal
  26. ECHO.
  27. ECHO Usage:  NUM2OCT  number
  28. ECHO.
  29. ECHO Where:  number   is a decimal or hexadecimal number
  30. ECHO                  (0xnnn for hexadecimal)
  31. ECHO.
  32. ECHO Note:   Non-numeric input will be treated as 0
  33. ECHO.
  34. ECHO Written by Rob van der Woude
  35. ECHO http://www.robvanderwoude.com
  36.  
  37. IF "%OS%"=="Windows_NT" EXIT /B 1
  38.  

page last uploaded: 2017-07-06, 12:37