Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::---------------------------------------------------------------------------------------
- :: Get the length of a string or number
- ::
- :: call :length "Hello World" varName
- :: echo %varName%
- ::---------------------------------------------------------------------------------------
- :length
- setlocal
- set "str=X%~1"
- set length=0
- for /L %%a in (8,-1,0) do (
- set /a "length|=1<<%%a"
- for %%b in (!length!) do if "!str:~%%b,1!" equ "" set /a "length&=~1<<%%a"
- )
- (endlocal
- if "%~2" neq "" ( set "%2=%length%" ) else echo %length%
- )
- goto :eof
- ::---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement