Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::---------------------------------------
- ::usage example ran from cmd.exe with stringlenght.bat either in path or the current directory:
- ::
- ::getstringlenght.bat 9223372036854775807
- ::
- ::cmd will respond with:
- ::
- ::19
- ::---------------------------------------
- @echo off&setlocal enabledelayedexpansion
- set "string=%~1"
- call :strlen ans string
- echo !ans!
- exit/b
- :strlen
- set l=0
- set "s=!%~2!#"
- for %%P in (512 256 128 64 32 16 8 4 2 1) do (
- if "!s:~%%P,1!" NEQ "" (
- set/a "l+=%%P"
- set "s=!s:~%%P!"
- )
- )
- set "%~1=%l%"
- exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement