Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SET %ERRORLEVEL%=0
- REM Error checks
- @IF "%~1"=="" (ECHO ERROR: No Input^! Try "Subtract help"&&PAUSE&&EXIT /b 1)
- @IF /I "%~1"=="help" goto help
- @IF "%~1"=="?" goto help
- @SET /a errorcheck=%~1 >nul 2>&1
- @IF NOT %ERRORLEVEL% EQU 0 (ECHO Subtract only accepts integer number input^! Try "Subtract Help"&&PAUSE&&EXIT /b 1)
- @IF "%~2"=="" (ECHO ERROR: Missing second input^! try "Subtract help"&&PAUSE&&EXIT /b 1)
- @SET /a errorcheck=%~2 >nul 2>&1
- @IF NOT %ERRORLEVEL% EQU 0 (ECHO Subtract only accepts integer number input^! Try "Subtract Help"&&PAUSE&&EXIT /b 1)
- REM Actual maths
- @SET /a "result=%1-%2"
- @ECHO %1 - %2 = %result%
- exit /b 0
- REM Help message
- :help
- ECHO Subtractition of two integer numbers
- ECHO.
- ECHO Example usage:
- ECHO Subtract [Number] [Number]
- ECHO Result is stored in ^%result^%
- ECHO.
- ECHO Subtract [?/help]
- ECHO Display this help message.
- ECHO.
- PAUSE
- EXIT /b 0
Add Comment
Please, Sign In to add comment