IcarusLives

Pow Function

Feb 18th, 2017
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.58 KB | None | 0 0
  1. ::---------------------------------------------------------------------------------------
  2. ::  square a number
  3. ::
  4. :: call :pow 12 2 RETURNVAR
  5. :: echo %RETURNVAR%
  6. ::---------------------------------------------------------------------------------------
  7. :pow
  8.     setlocal
  9.         set "out=1"
  10.         for /l %%a in (1,1,%2) do set /a "out*=%1"
  11.         if %~1 equ 0 set "out=1"
  12.        
  13.         (endlocal
  14.             if "%~3" neq "" ( set "%~3=%out%" ) else echo %out%
  15.         )
  16. goto :eof
  17. ::---------------------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment