BatchHacker

Count and Print from a pos

Jun 20th, 2014
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off & setlocal
  2. mode con:cols=400 lines=80
  3. setlocal EnableDelayedExpansion
  4. :none
  5. cls
  6. echo Type a text.
  7. set text=nothing
  8. set /p text=Text:
  9. set text=%text:"=%
  10. set text=%text:^>=%
  11. set text=%text:^<=%
  12. set text=%text:,=%
  13. set text=%text:^^=%
  14. set myString=%text%
  15. call :strlen result myString
  16. echo %result%
  17. set Output=%text%
  18. set count=1
  19. :loop
  20. echo %Output%
  21. set "Output=!Output:~1,%result%!"
  22. set /a count=%count%+1
  23. if "%count%"=="%result%" goto stopLoop
  24. if "%Output%"=="" goto stopLoop
  25. goto loop
  26. :stopLoop
  27. pause
  28. goto none
  29. :strlen <resultVar> <stringVar>
  30. if "%text%"=="nothing" goto none
  31. (  
  32.     set "s=!%~2!#"
  33.     set "len=0"
  34.     for %%P in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (
  35.         if "!s:~%%P,1!" NEQ "" (
  36.             set /a "len+=%%P"
  37.             set "s=!s:~%%P!"
  38.         )
  39.     )
  40. )
  41. (
  42.     endlocal
  43.     set "%~1=%len%"
  44.     exit /b
  45. )
  46. pause
  47. goto none
Advertisement
Add Comment
Please, Sign In to add comment