ch4rl1e97

Subtract.bat

Sep 12th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.90 KB | None | 0 0
  1. @SET %ERRORLEVEL%=0
  2. REM Error checks
  3. @IF "%~1"=="" (ECHO ERROR: No Input^! Try "Subtract help"&&PAUSE&&EXIT /b 1)
  4.  
  5. @IF /I "%~1"=="help" goto help
  6.  
  7. @IF "%~1"=="?" goto help
  8.  
  9.  
  10.  
  11. @SET /a errorcheck=%~1 >nul 2>&1
  12. @IF NOT %ERRORLEVEL% EQU 0 (ECHO Subtract only accepts integer number input^! Try "Subtract Help"&&PAUSE&&EXIT /b 1)
  13. @IF "%~2"=="" (ECHO ERROR: Missing second input^! try "Subtract help"&&PAUSE&&EXIT /b 1)
  14. @SET /a errorcheck=%~2 >nul 2>&1
  15. @IF NOT %ERRORLEVEL% EQU 0 (ECHO Subtract only accepts integer number input^! Try "Subtract Help"&&PAUSE&&EXIT /b 1)
  16.  
  17. REM Actual maths
  18. @SET /a "result=%1-%2"
  19. @ECHO %1 - %2 = %result%
  20. exit /b 0
  21.  
  22. REM Help message
  23. :help
  24. ECHO Subtractition of two integer numbers
  25. ECHO.
  26. ECHO Example usage:
  27. ECHO Subtract [Number] [Number]
  28. ECHO Result is stored in ^%result^%
  29. ECHO.
  30. ECHO Subtract [?/help]
  31. ECHO Display this help message.
  32. ECHO.
  33. PAUSE
  34. EXIT /b 0
Add Comment
Please, Sign In to add comment