Advertisement
npocmaka

PushDCounter1.1

May 8th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :pushd_counter
  2. rem -- prints pushd level stack
  3. rem -- by Vasil "npocmaka" Arnaudov
  4. @echo off
  5. set prompt_backup=%prompt%
  6. prompt $+
  7. ( echo on
  8.    for %%a in (1) do ( @rem
  9.    )
  10. )>%temp%\p.tmp
  11. @echo off
  12. prompt %prompt_backup%
  13. set "prompt_backup="
  14. for /f "usebackq tokens=1 delims=() " %%P in ("%temp%\p.tmp") do (
  15.         set s=%%P
  16. )
  17. del %temp%\p.tmp  /q >nul
  18. setlocal EnableDelayedExpansion
  19.   set "s=#!s!"
  20.   set "len=0"
  21.   for %%A in (2187 729 243 81 27 9 3 1) do (
  22.         set /A mod=2*%%A
  23.         for %%Z in (!mod!) do (
  24.                 if "!s:~%%Z,1!" neq "" (
  25.                         set /a "len+=%%Z"
  26.                         set "s=!s:~%%Z!"
  27.                        
  28.                 ) else (
  29.                         if "!s:~%%A,1!" neq "" (
  30.                                 set /a "len+=%%A"
  31.                                 set "s=!s:~%%A!"
  32.                         )
  33.                 )
  34.         )
  35.   )
  36. endlocal &  echo %len%
  37. set "s="
  38. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement