(view source code of dectooct.bat as plain text)
@ECHO OFF
SETLOCAL
SET /A Decimal = %1 +0 >NUL 2>&1 || GOTO Syntax
IF %Decimal% LSS 0 GOTO Syntax
SET Octal=
SET Scratch=%Decimal%
:Loop
SET /A LSB = %Scratch% %% 8
SET /A "Scratch = %Scratch% >> 3"
SET Octal=%LSB%%Octal%
IF NOT %Scratch% EQU 0 GOTO Loop
SET Octal=0%Octal%
SET Decimal
SET Octal
SET RC=0
IF NOT %Decimal% EQU %Octal% (
ECHO An error occurred, %Octal% is not equal to %Decimal%
SET RC=1
)
ENDLOCAL & EXIT /B %RC%
:Syntax
ECHO.
ECHO DecToOct.bat, Version 1.01
ECHO Convert a decimal number to "10.5" digit octal
ECHO.
ECHO Usage: DECTOOCT number
ECHO.
ECHO Where: number is a 32-bit positive integer or calculation
ECHO (0..2,147,483,647 or 0..017777777777)
ECHO.
ECHO Notes: This batch file uses CMD.EXE's internal commands only.
ECHO Return code ("ErrorLevel") 0 if conversion was successful,
ECHO otherwise 1.
ECHO.
ECHO Written by Rob van der Woude
ECHO https://www.robvanderwoude.com
ENDLOCAL
EXIT /B 1
page last modified: 2024-04-16; loaded in 0.0077 seconds