Well, Francesco, I tinkered with the macros until they got faster and achieved this performance
The quotation marks can be omitted everywhere if the variable expansion does not contain a comma.
The closing brackets are attached directly to the variables to be set, as is the follow-up command.
set /a statements are probably a little slower than direct variable creation.
I've been using the if with a single exclamation mark for a while now, and this means that the comparison can also be done without quotation marks.
Yes, and this also makes calculations and variable expansion with hexadecimal numbers easier.
And I've made the batch/CMD version a little easier.
If the macro is only to be processed in batch mode, the variable expansion with commas can simply be escaped (as can other characters that require this).
The latest version is now even faster.
If the quotation marks are removed, the macro runs.
However, this is only suitable for batch processing because escaping reacts differently in the CMD line.
So much for the speedup.
Yes, I updated the test script again... you know, a new version.
Hopefully I won't run out of letters.
but so many complicated processes came to mind that I had to play around on the keyboard.
And so I had to continue with “z”.
One would hope that operating systems would finally stop with the updates at “a”,
but they constantly come up with new nonsense, and that's why it continues at the back.
Code: Select all
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: make sure we are in the spotlight:
:: run as administrator for realtime priorities, else you will get "high" priorities
:: /affinity 0x3 = 2 core/thread
@if "%~1"=="" start /realtime conhost "%~f0" 1&exit /b
@echo off & setlocal DisableDelayedExpansion
:reduceEnvironment -- remove unnecessary variables
for /f "tokens=1-2 delims=;" %%i in ("cmd.exe;.") do (
for /f "delims==-" %%i in ('2^>nul set') do set "%%i="
set "COMSPEC=%COMSPEC%"
set "Path=%%~dp$PATH:i"
set "PATHEXT=%PATHEXT%"
set "prompt=$G$S"
set "temp=%temp%"
set "windir=%windir%"
)
:: 8191
rem 16 32 64 128 256 512 1024 2048 4096
call call call call call call call call call set "x=^^^^^^^^X"
set "x=%x:~1%"
set str1=^
%x:^= %
set "x="
echo(
echo Check length str1 gtr 8190 %str1:~8190%
:: 6000
set "str2=%str1:~,6000%"
:: 4000
set "str3=%str1:~,4000%"
:: 2000
set "str4=%str1:~,2000%"
:: 1000
set "str5=%str1:~,1000%"
set "str510=%str1:~,510%
set "str511=%str1:~,511%
set "str512=%str1:~,512%
:: 200
set "str6=%str1:~,200%"
:: 10
set "str7=%str1:~,10%"
call :initTimediff
:: Test echo OFF =1 ON =[empty]
for %%T in ( 1 ) do set testecho=rem
goto :beginTestOld
"2 Final"
"2a TEST"
"2b TEST"
"2c TEST"
"2d TEST"
"2e TEST"
"2f TEST"
"2i TEST"
"2y TEST"
"2z TEST"
"All Batch and CMDline"
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:BeginTestOld
set /a times_func=3
set /a times_test=1200
set skip1-7= rem
:goto :endTestOld
for %%A in (
"2v TEST"
"2w TEST"
"2x TEST"
"2y TEST"
"All Batch and CMDline"
) do (
echo(
echo ~~~~~~~~~~~~~~~~~~~~
echo %%A
set Mark=%%~A
setlocal enabledelayedexpansion
if ! gtr ' (echo Delayed OFF) else echo Delayed ON
call :initStrLen%%Mark:~0,9%% StrLen
%testecho% echo on
%skip1-7% call :test str1
%skip1-7% call :test str2
%skip1-7% call :test str3
%skip1-7% call :test str4
%skip1-7% call :test str5
%skip1-7% call :test str6
%skip1-7% call :test str7
%skip1-7% call :test str510
%skip1-7% call :test str511
%skip1-7% call :test str512
%skip1-7% call :test str0
%testecho% pause
%testecho% echo off
echo Functional test 0 ... 8189 + 8191 with Delayedexpansion ON ^(create macro^)
call :func_test
endlocal
if ! gtr ' (echo Delayed OFF) else echo Delayed ON
call :initStrLen%%Mark:~0,9%% StrLen
%testecho% echo on
%skip1-7% call :test str1
%testecho% pause
%testecho% echo off
%skip1-7% call :test str2
%skip1-7% call :test str3
%skip1-7% call :test str4
%skip1-7% call :test str5
%skip1-7% call :test str6
%skip1-7% call :test str7
%skip1-7% call :test str0
echo Functional test 0 ... 8189 + 8191 with Delayedexpansion OFF ^(create macro^)
call :func_test
)
echo(done
set "StrLen="
rem End Test Old
:endTestOld
if ! gtr ' (echo Delayed OFF) else echo Delayed ON
goto :useOnlyThisVersions
call :initStrLen1 StrLen1
call :initStrLen2 StrLen2
call :initStrLen2i StrLen2i
call :initStrLen2f StrLen2f
call :initStrLen2e StrLen2e
call :initStrLen2d StrLen2d
call :initStrLen2c StrLen2c
call :initStrLen2b StrLen2b
call :initStrLen2z StrLen2z
:useOnlyThisVersions
call :initStrLen2b StrLen2b
call :initStrLen2a StrLen2a
call :initStrLen2y StrLen2y
call :initStrLen2x StrLen2x
call :initStrLen2w StrLen2w
call :initStrlen2v StrLen2v
call :initStrLenAll
%testecho% pause
::::::: rem var HeaderInfo is required to create the table header automatically
::::::: !!! >> and if Macro loaded << !!!
:::::::::::::
::: oh no not so much otherwise the monitor on the right side will break
:set "HeaderInfo= final1 2z 2a 2b 2c 2d 2e all 2f 2i final2 final1"
set "HeaderInfo=all 2v 2w 2x 2y 2a 2b all"
set /a times=times_test*7
set /a times_random=20
set /a TABi=0
set "test_StrLength=0 6000 4000 4500 1000 600 200 10 1"
for /f %%0 in ("! '") do (
if %%0 GTR ' setlocal enabledelayedexpansion
for /l %%N in (1 1 %times_random%) do (
for /f %%N in ('set /a !random! %%8191') do set test_StrLength=!test_StrLength! %%N)
call :testx str1 len %HeaderInfo%
for %%N in (!test_StrLength!) do (set strX=^
!str1:~,%%~N!
call :testx strX len %HeaderInfo%
)
if %%0 lss ' endlocal
)
pause
goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::
:func_test
setlocal enabledelayedexpansion
set /a NN=1
:againf_t
set "t1=!time!"
for /L %%L in (0,1,8189) do (
set A=^
!str1:~,%%L!
%strLen% A len
if !len! neq %%L echo in %%L out !len!
)
%strLen% str1 len
if !len! neq 8191 echo in 8191 out !len!
set t2=!time!
%timediff% t1 t2 diff
echo !diff:~6!
if %NN% equ %times_func% goto :eof
set /a nn+=1
goto :againf_t
:test
set len=
%strLen% %1 len
echo Check: len=%len%
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:testx
if defined lineX goto :testXnext
:::::::param: strVar Dummy(writeLen) HeaderInfo
set /a columns=1, tablines=10
::HeaderInfo=1stheadColumn X Y n
%= buildHeader =%
set "line="
set "lineX="
::::::: Column two, the first column with the time output,
::::::: can be safely ignored—it's always too high,
::::::: no matter which macro is run first.
::::::: The second time column with the same macro will output a correct value.
:::::::::::::::
:::::::: rem HeaderInfo is required to create the table header automatically
for /l %%l in (1 1 3) do for %%h in (x%times% %HeaderInfo% 0) do (
if "!lineX!" equ "" if %%l equ 1 if %%h neq 0 (set "line=!line!+--------"
) else set "linex=!line!+"&echo !linex!
if %%l equ 2 if %%h neq 0 (
set "name=%%~h "
for /l %%L in (1 1 4) do if "!name:~8,1!" equ "" set "name= !name! "
<nul set/p "=I!name:~0,8!"
) else echo I
if %%l equ 3 if %%h equ 0 echo !linex!
)
:testXnext
set /a i=0
:beginloop
call :loop %*
set /a i+=1,TABi+=1
if !i! lss !columns! goto :beginloop
2>nul set /a X=1/(TABi%%tablines)||echo !linex!&&set "linex="
goto :eof
:loop
set /a N=1
:versions
:::::::::::::::::::::::::::
:: rem Pro[ver] [times] [stringVar]
call :pro%2 %times% %1
if !N! equ 1 <nul (
set/p "=I !len! "
) else (
%timediff% t1 t2 diff
<nul set/p.="I !diff:~6! "
)
set /a N+=1
if "%3" equ "" (
echo I
goto :eof
)
shift /1
goto :versions
goto :eof
:Pro = [times] [stringVar]
:proFinal1
set t1=!time!
for /l %%i in (1 1 %1) do %strLen1% %2 len
set t2=!time!
goto :eof
:proFinal2
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2% %2 len
set t2=!time!
goto :eof
:pro2i
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2i% %2 len
set t2=!time!
goto :eof
:pro2f
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2f% %2 len
set t2=!time!
goto :eof
:pro2e
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2e% %2 len
set t2=!time!
goto :eof
:pro2d
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2e% %2 len
set t2=!time!
goto :eof
:pro2c
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2c% %2 len
set t2=!time!
goto :eof
:pro2b
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2b% %2 len
set t2=!time!
goto :eof
:pro2a
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2a% %2 len
set t2=!time!
goto :eof
:pro2z
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2z% %2 len
set t2=!time!
goto :eof
:pro2y
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2y% %2 len
set t2=!time!
goto :eof
:pro2x
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2x% %2 len
set t2=!time!
goto :eof
:pro2w
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2w% %2 len
set t2=!time!
goto :eof
:pro2v
set t1=!time!
for /l %%i in (1 1 %1) do %strLen2v% %2 len
set t2=!time!
goto :eof
:proAll
set t1=!time!
for /l %%i in (1 1 %1) do %strLen% %2 len
set t2=!time!
goto :eof
:prolen
set t1=!time!
for /l %%i in (1 1 2) do %strLen2y% %2 len
set t2=!time!
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen1 Final
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
FOR /F %%! IN ("! ^! ^^^!") DO ^
set %~1=^
for /f "tokens=2" %%? in ("%%!%%! D E") do for %%. in (1 2) do if %%.==2 (^
for /f "tokens=1,2" %%1 in ("%%!$args%%!") do (^
set "$L=0"^&^
(if defined %%~1^
(if "" neq "%%!%%~1:~255%%!"^
(if "" neq "%%!%%~1:~4095%%!"^
(set "$=%%!%%~1:~4096%%!"^&set "$L=4096") else set "$=%%!%%~1%%!"^
)^&^
(if defined $^
set ^"$scale=^
%%!$:~255,1%%!%%!$:~511,1%%!%%!$:~767,1%%!%%!$:~1023,1%%!%%!$:~1279,1%%!^
%%!$:~1535,1%%!%%!$:~1791,1%%!%%!$:~2047,1%%!%%!$:~2303,1%%!%%!$:~2559,1%%!^
%%!$:~2815,1%%!%%!$:~3071,1%%!%%!$:~3327,1%%!%%!$:~3583,1%%!%%!$:~3839,1%%!^
FEDCBA9876543210^"^&^
set /a "$L+=0x%%!$scale:~15,1%%!*256"^
)^
)^&^
for %%# in (%%!$L%%!) do set ^"$=%%!%%~1:~%%#%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
333333333333333322222222222222221111111111111111^"^&^
set /a "$L+=0x%%!$:~511,1%%!%%!$:~255,1%%!"^
)^&^
for %%# in (%%!$L%%!) do (if %%?==D endlocal)^&set "%%~2=%%#"^
)^
) else (if %%?==D setlocal EnableDelayedExpansion)^& set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
FOR %%H IN (FEDCBA9876543210) DO FOR /F %%! IN ("! ^! ^^^!") DO ^
set %~1=^
%==% for /f "tokens=2" %%? in ("%%!%%! D E") do for %%. in (1 2) do if %%.==2 (^
%= =% for /f "tokens=1,2" %%1 in ("%%!$args%%!") do for %%3 in (%%~1) do (^
%= =% if defined %%3 (^
%= =% (^
%= =% if "" neq "%%!%%3:~255%%!" (^
%= =% if "" neq "%%!%%3:~4095%%!" (^
%= =% set "$=%%!%%3:~4096%%!"^
%= =% ) else set "$=%%!%%3%%!"^
%= =% ) ^& (^
%= =% if defined $ (^
%= =% set ^"$Scale=^
%= =%%%!$:~255,1%%!%%!$:~511,1%%!%%!$:~767,1%%!%%!$:~1023,1%%!^
%= =%%%!$:~1279,1%%!%%!$:~1535,1%%!%%!$:~1791,1%%!%%!$:~2047,1%%!^
%= =%%%!$:~2303,1%%!%%!$:~2559,1%%!%%!$:~2815,1%%!%%!$:~3071,1%%!^
%= =%%%!$:~3327,1%%!%%!$:~3583,1%%!%%!$:~3839,1%%!%%H^"^&^
%= =% if "" neq "%%!%%3:~4095%%!" (^
%= =% set /a "$L=0x%%!$Scale:~15,1%%!*256+4096"^
%= =% ) else set /a "$L=0x%%!$Scale:~15,1%%!*256"^
%= =% ) else if "" neq "%%!%%3:~4095%%!" set "$L=4096"^
%= =% ) else set "$L=0"^
%= =% )^&^
%= =% for %%# in (%%!$L%%!) do set ^"$=%%!%%3:~%%#%%!^
%= =%%%H%%H%%H%%H%%H%%H%%H%%H%%H%%H%%H%%H%%H%%H%%H%%H^
%= =%FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
%= =%BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
%= =%7777777777777777666666666666666655555555555555554444444444444444^
%= =%333333333333333322222222222222221111111111111111^"^&^
%= =% for %%# in ("%%!$L%%!+0x%%!$:~511,1%%!%%!$:~255,1%%!") do (^
%= =% (if %%?==D endlocal)^&set /A "%%~2=%%#"^
%= =% )^
%= =% ) else (if %%?==D endlocal)^&set "%%~2=0"^
%= =% )^
%==% ) else (if %%?==D setlocal EnableDelayedExpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2i
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
FOR /F %%! IN ("! ^! ^^^!") DO ^
set %~1=^
for /f %%? in ("%%!%%! '") do for %%. in (1 2) do if %%.==2 (^
for /f "tokens=1,2" %%1 in ("%%!$args%%!") do if defined %%~1 (^
(if "%%!%%~1:~4095,1%%!" equ "" (set "$L="^&set "$=A%%!%%1%%!"^
) else set "$L=1"^&set "$=A%%!%%1:~4096%%!"^
)^& set ^"$Scale=^
%%!$:~256,1%%!%%!$:~512,1%%!%%!$:~768,1%%!%%!$:~1024,1%%!%%!$:~1280,1%%!^
%%!$:~1536,1%%!%%!$:~1792,1%%!%%!$:~2048,1%%!%%!$:~2304,1%%!%%!$:~2560,1%%!^
%%!$:~2816,1%%!%%!$:~3072,1%%!%%!$:~3328,1%%!%%!$:~3584,1%%!%%!$:~3840,1%%!^
FEDCBA9876543210^"^&^
set /a "$L=0x%%!$L%%!%%!$Scale:~15,1%%!00"^&^
for %%# in (%%!$L%%!) do set ^"$=%%!%%1:~%%#%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
333333333333333322222222222222221111111111111111^"^&^
for %%# in ("%%#+0x%%!$:~511,1%%!%%!$:~255,1%%!") do (if %%? lss ' endlocal)^&set /A "%%~2=%%~#"^
) else (if %%? lss ' endlocal)^&set "%%~2=0"^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2f
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
FOR /F %%! IN ("! ^! ^^^!") DO ^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 (^
for /f "tokens=1,2" %%1 in ("%%!$args%%! len") do if defined %%~1 (^
(if "%%!%%~1:~4095,1%%!" equ "" (set "$L=0"^&set "$=A%%!%%1%%!"^
) else set "$L=1"^&set "$=A%%!%%1:~4096%%!"^
)^& set ^"$Scale=^
%%!$:~256,1%%!%%!$:~512,1%%!%%!$:~768,1%%!%%!$:~1024,1%%!%%!$:~1280,1%%!^
%%!$:~1536,1%%!%%!$:~1792,1%%!%%!$:~2048,1%%!%%!$:~2304,1%%!%%!$:~2560,1%%!^
%%!$:~2816,1%%!%%!$:~3072,1%%!%%!$:~3328,1%%!%%!$:~3584,1%%!%%!$:~3840,1%%!^
FEDCBA9876543210^"^&^
for /f %%# in ("%%!$Scale:~15,1%%!") do set ^"$=%%!$:~0x%%#00%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^"^&^
for /f %%# in ("0x%%!$L%%!%%#%%!$:~512,1%%!%%!$:~256,1%%!") do (^
if %%? lss ' endlocal)^&set /A "%%~2=%%#"^
) else (if %%? lss ' endlocal)^&set "%%~2=0"^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2e
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
:: this Version is for use only in Batch
%== ! -> exclamation mark, # -> caret ==% FOR /F "tokens=1-3" %%! IN (
"! ^! ^ ^^^! . ^^^^") DO ^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 (^
for /f "tokens=1,2" %%1 in ("%%!$args%%! len") do if defined %%1 (^
(if %%! neq %%!%%1:~4095%%! (set $L=1^&set $=A%%!%%1:~4096%%!) else ^
set $L=0^&set $=A%%!%%1%%!)^& set $Scale=^
%%!$:~256%%#,1%%!%%!$:~512%%#,1%%!%%!$:~768%%#,1%%!%%!$:~1024%%#,1%%!%%!$:~1280%%#,1%%!^
%%!$:~1536%%#,1%%!%%!$:~1792%%#,1%%!%%!$:~2048%%#,1%%!%%!$:~2304%%#,1%%!%%!$:~2560%%#,1%%!^
%%!$:~2816%%#,1%%!%%!$:~3072%%#,1%%!%%!$:~3328%%#,1%%!%%!$:~3584%%#,1%%!%%!$:~3840%%#,1%%!^
FEDCBA9876543210^&^
for %%$ in (%%!$Scale:~15%%#,1%%!) do set $=%%!$:~0x%%$00%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
for %%$ in (0x%%!$L%%!%%$%%!$:~512%%#,1%%!%%!$:~256%%#,1%%!) do (^
if %%? lss ' endlocal)^&set /A %%~2=%%$^
) else (if %%? lss ' endlocal)^&set /a %%~2=0^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2d
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
:: this Version is for use only in Batch
%== ! -> exclamation mark, # -> caret ==% FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO ^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 (^
for /f "tokens=1,2" %%1 in ("%%!$args%%! len") do if defined %%1 (^
(if : neq :%%!%%1:~4095%%! (set $=1%%!%%1:~4096%%!) else ^
set $=0%%!%%1%%!)^& set $Scale=^
%%!$:~256%%#,1%%!%%!$:~512%%#,1%%!%%!$:~768%%#,1%%!%%!$:~1024%%#,1%%!%%!$:~1280%%#,1%%!^
%%!$:~1536%%#,1%%!%%!$:~1792%%#,1%%!%%!$:~2048%%#,1%%!%%!$:~2304%%#,1%%!%%!$:~2560%%#,1%%!^
%%!$:~2816%%#,1%%!%%!$:~3072%%#,1%%!%%!$:~3328%%#,1%%!%%!$:~3584%%#,1%%!%%!$:~3840%%#,1%%!^
FEDCBA9876543210^&^
for %%$ in (%%!$Scale:~15%%#,1%%!) do set $=%%!$:~%%#,1%%!%%!$:~0x%%$00%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
for %%$ in (%%!$:~%%#,1%%!%%$%%!$:~513%%#,1%%!%%!$:~257%%#,1%%!) do (^
if %%? lss ' endlocal)^&set /A %%~2=0x%%$^
) else (if %%? lss ' endlocal)^&set /a %%~2=0^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2c
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO @^
set %~1=^
for /f %%? in ("%%! '") do @for %%. in (1 2) do if %%.==2 (^
for /f "tokens=1,2" %%1 in ("%%!$args%%! len") do if defined %%1 ^
(if : neq :%%!%%1:~4095%%! set $=1%%!%%1:~4096%%!^&call)^&^&set $=0%%!%%1%%!^&^
set $Scale=^
%%!$:~256%%#,1%%!%%!$:~512%%#,1%%!%%!$:~768%%#,1%%!%%!$:~1024%%#,1%%!%%!$:~1280%%#,1%%!^
%%!$:~1536%%#,1%%!%%!$:~1792%%#,1%%!%%!$:~2048%%#,1%%!%%!$:~2304%%#,1%%!%%!$:~2560%%#,1%%!^
%%!$:~2816%%#,1%%!%%!$:~3072%%#,1%%!%%!$:~3328%%#,1%%!%%!$:~3584%%#,1%%!%%!$:~3840%%#,1%%!^
FEDCBA9876543210^&^
for %%$ in (%%!$Scale:~15%%#,1%%!) do set $=%%!$:~%%#,1%%!%%!$:~0x%%$00%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
(for %%$ in (%%!$:~%%#,1%%!%%$%%!$:~513%%#,1%%!%%!$:~257%%#,1%%!) do (if %%? lss ' endlocal)^&set /A %%~2=0x%%$^
) else (if %%? lss ' endlocal)^&set /a %%2=0^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
else (if %%? lss ' endlocal)^&set /a %%2=0^
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2b
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO @^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 (^
for /f "tokens=1,2" %%1 in ("%%!$args%%! len") do^
if not defined %%1 (if %%? lss ' endlocal)^&(set /a %%2=0) else^
(if : neq :%%!%%1:~4095%%! set $=1%%!%%1:~4096%%!^&call)^&^&set $=0%%!%%1%%!^&^
set $Scale=^
%%!$:~256%%#,1%%!%%!$:~512%%#,1%%!%%!$:~768%%#,1%%!%%!$:~1024%%#,1%%!%%!$:~1280%%#,1%%!^
%%!$:~1536%%#,1%%!%%!$:~1792%%#,1%%!%%!$:~2048%%#,1%%!%%!$:~2304%%#,1%%!%%!$:~2560%%#,1%%!^
%%!$:~2816%%#,1%%!%%!$:~3072%%#,1%%!%%!$:~3328%%#,1%%!%%!$:~3584%%#,1%%!%%!$:~3840%%#,1%%!^
FEDCBA9876543210^&^
for %%$ in (%%!$Scale:~15%%#,1%%!) do set $=%%!$:~%%#,1%%!%%!$:~0x%%$00%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
for %%$ in (%%!$:~%%#,1%%!%%$%%!$:~513%%#,1%%!%%!$:~257%%#,1%%!) do^
(if %%? lss ' endlocal)^&set /A %%2=0x%%$^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2a
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO @^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 (^
for /f "tokens=1,2" %%1 in ("%%!$args%%! len") do^
if not defined %%1 (if %%? lss ' endlocal)^&(set /a %%2=0) else^
(if : neq :%%!%%1:~4095%%! (set $=1%%!%%1:~4096%%!) else set $=0%%!%%1%%!)^&^
set $Scale=^
%%!$:~256%%#,1%%!%%!$:~512%%#,1%%!%%!$:~768%%#,1%%!%%!$:~1024%%#,1%%!%%!$:~1280%%#,1%%!^
%%!$:~1536%%#,1%%!%%!$:~1792%%#,1%%!%%!$:~2048%%#,1%%!%%!$:~2304%%#,1%%!%%!$:~2560%%#,1%%!^
%%!$:~2816%%#,1%%!%%!$:~3072%%#,1%%!%%!$:~3328%%#,1%%!%%!$:~3584%%#,1%%!%%!$:~3840%%#,1%%!^
FEDCBA9876543210^&^
for %%$ in (%%!$Scale:~15%%#,1%%!) do set $=%%!$:~%%#,1%%!%%!$:~0x%%$00%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
for %%$ in (%%!$:~%%#,1%%!%%$%%!$:~513%%#,1%%!%%!$:~257%%#,1%%!) do^
(if %%? lss ' endlocal)^&set /A %%2=0x%%$^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2z
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO @^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 ^
for /f tokens%%#=1-2 %%1 in ("%%!$args%%! len") do^
if not defined %%1 (if %%? lss ' endlocal)^&(set /a %%2=0) else^
for /f tokens%%#=4%%#,6delims%%#=%%# %%4 in^
("x %%!%%1:~4095,1%%! x%%!%%1:~4095,1%%!x 1 0 4096") do^
set $=A%%!%%1:~%%5%%!^&set $=%%!$: =.%%!^&^
for /f usebackqtokens%%#=16delims%%#=%%# %%3 in (' %%!$:~256%%#,1%%! ^
%%!$:~512%%#,1%%! %%!$:~768%%#,1%%! %%!$:~1024%%#,1%%! %%!$:~1280%%#,1%%! ^
%%!$:~1536%%#,1%%! %%!$:~1792%%#,1%%! %%!$:~2048%%#,1%%! %%!$:~2304%%#,1%%! ^
%%!$:~2560%%#,1%%! %%!$:~2816%%#,1%%! %%!$:~3072%%#,1%%! %%!$:~3328%%#,1%%! ^
%%!$:~3584%%#,1%%! %%!$:~3840%%#,1%%! F E D C B A 9 8 7 6 5 4 3 2 1 0 ^
') do set $=%%!$:~0x%%300%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
for %%$ in (%%4%%3%%!$:~512%%#,1%%!%%!$:~256%%#,1%%!) do^
(if %%? lss ' endlocal)^&(set /A %%2=0x%%$^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2y
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO @^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 ^
for /f tokens%%#=1-2 %%1 in ("%%!$args%%! len") do^
if not defined %%1 (if %%? lss ' endlocal)^&(set /a %%2=0) else^
for /f tokens%%#=4delims%%#=%%# %%4 in^
("x %%!%%1:~4095,1%%! x%%!%%1:~4095,1%%!x 1 0") do set $=A%%!%%1:~0x%%4000%%!^&^
set $Scale=^
%%!$:~256%%#,1%%!%%!$:~512%%#,1%%!%%!$:~768%%#,1%%!%%!$:~1024%%#,1%%!%%!$:~1280%%#,1%%!^
%%!$:~1536%%#,1%%!%%!$:~1792%%#,1%%!%%!$:~2048%%#,1%%!%%!$:~2304%%#,1%%!%%!$:~2560%%#,1%%!^
%%!$:~2816%%#,1%%!%%!$:~3072%%#,1%%!%%!$:~3328%%#,1%%!%%!$:~3584%%#,1%%!%%!$:~3840%%#,1%%!^
FEDCBA9876543210^&^
for %%3 in (%%!$Scale:~15%%#,1%%!) do set $=%%!$:~0x%%300%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
for %%$ in (%%4%%3%%!$:~512%%#,1%%!%%!$:~256%%#,1%%!) do^
(if %%? lss ' endlocal)^&(set /A %%2=0x%%$^
)else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2x
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO @^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 ^
for /f tokens%%#=1-2 %%1 in ("%%!$args%%! len") do^
if not defined %%1 (if %%? lss ' endlocal)^&(set /A %%2=0) else^
for /f tokens%%#=3delims%%#=%%# %%4 in (^
" %%!%%1:~4095,1%%! x%%!%%1:~4095,1%%!x 1 0") do set $=A%%!%%1:~0x%%4000%%!^&^
for /f tokens%%#=31delims%%#=%%# %%3 in (^"^
%%!$:~3840,1%%! x%%!$:~3840,1%%!x %%!$:~3584,1%%! x%%!$:~3584,1%%!x^
%%!$:~3328,1%%! x%%!$:~3328,1%%!x %%!$:~3072,1%%! x%%!$:~3072,1%%!x^
%%!$:~2816,1%%! x%%!$:~2816,1%%!x %%!$:~2560,1%%! x%%!$:~2560,1%%!x^
%%!$:~2304,1%%! x%%!$:~2304,1%%!x %%!$:~2048,1%%! x%%!$:~2048,1%%!x^
%%!$:~1792,1%%! x%%!$:~1792,1%%!x %%!$:~1536,1%%! x%%!$:~1536,1%%!x^
%%!$:~1280,1%%! x%%!$:~1280,1%%!x %%!$:~1024,1%%! x%%!$:~1024,1%%!x^
%%!$:~768,1%%! x%%!$:~768,1%%!x %%!$:~512,1%%! x%%!$:~512,1%%!x^
%%!$:~256,1%%! x%%!$:~256,1%%!x F E D C B A 9 8 7 6 5 4 3 2 1 0 ^") do^
set $=%%!$:~0x%%300%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
for %%$ in (%%4%%3%%!$:~512%%#,1%%!%%!$:~256%%#,1%%!) do^
(if %%? lss ' endlocal)^&(set /A %%2=0x%%$^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
@goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2w
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO @^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 ^
for /f tokens%%#=1-2 %%1 in ("%%!$args%%! len") do^
if not defined %%1 (if %%? lss ' endlocal)^&(set /A %%2=0) else^
for /f tokens%%#=3delims%%#=%%# %%4 in (^
" %%!%%1:~4095,1%%! x%%!%%1:~4095,1%%!x 1 0") do^
for /f tokens%%#=31delims%%#=%%# %%3 in (^"^
%%!%%1:~0x%%4eff,1%%! x%%!%%1:~0x%%4eff,1%%!x %%!%%1:~0x%%4dff,1%%! x%%!%%1:~0x%%4dff,1%%!x^
%%!%%1:~0x%%4cff,1%%! x%%!%%1:~0x%%4cff,1%%!x %%!%%1:~0x%%4bff,1%%! x%%!%%1:~0x%%4bff,1%%!x^
%%!%%1:~0x%%4aff,1%%! x%%!%%1:~0x%%4aff,1%%!x %%!%%1:~0x%%49ff,1%%! x%%!%%1:~0x%%49ff,1%%!x^
%%!%%1:~0x%%48ff,1%%! x%%!%%1:~0x%%48ff,1%%!x %%!%%1:~0x%%47ff,1%%! x%%!%%1:~0x%%47ff,1%%!x^
%%!%%1:~0x%%46ff,1%%! x%%!%%1:~0x%%46ff,1%%!x %%!%%1:~0x%%45ff,1%%! x%%!%%1:~0x%%45ff,1%%!x^
%%!%%1:~0x%%44ff,1%%! x%%!%%1:~0x%%44ff,1%%!x %%!%%1:~0x%%43ff,1%%! x%%!%%1:~0x%%43ff,1%%!x^
%%!%%1:~0x%%42ff,1%%! x%%!%%1:~0x%%42ff,1%%!x %%!%%1:~0x%%41ff,1%%! x%%!%%1:~0x%%41ff,1%%!x^
%%!%%1:~0x%%40ff,1%%! x%%!%%1:~0x%%40ff,1%%!x F E D C B A 9 8 7 6 5 4 3 2 1 0^") do^
set $=%%!%%1:~0x%%4%%300%%!^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210^
FFFFFFFFFFFFFFFFEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCC^
BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA99999999999999998888888888888888^
7777777777777777666666666666666655555555555555554444444444444444^
3333333333333333222222222222222211111111111111110000000000000000^&^
for %%$ in (0x%%4%%3%%!$:~511%%#,1%%!%%!$:~255%%#,1%%!) do^
(if %%? lss ' endlocal)^&(set /A %%2=%%$^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
@goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2v
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
FOR /F %%! IN ("! ! ^ ^^^^^^^^^^^!") DO set i=%%!%%1:~03777,1%%!^
x%%!%%1:~03777,1%%!x&set o=%%!%%1:~0%%4777,1%%! x%%!%%1:~0%%4777,1%%!x^
%%!%%1:~0%%4377,1%%! x%%!%%1:~0%%4377,1%%!x
set F=FEDCBA9876543210&set $=0000000000000000
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO ^
set %~1=^
for /f %%? in ("%%! '") do for %%. in (1 2) do if %%.==2 ^
for /f tokens%%#=1-2 %%1 in ("%%!$args%%! len") do^
if not defined %%1 (if %%? lss ' endlocal)^&(set /A %%2=0) else^
for /f "tokens=7,11,15,19delims= " %%4 in (^"^
%i% %i:3=7% %i:3=13% 17 13 7 3 16 12 6 2 15 11 5 1 14 10 4 0^") do^
for /f tokens%%#=15delims%%#=%%# %%3 in (^" %o:4=7% %o:4=6% %o:4=5% %o:*x =%^
%%44 %%40 %%54 %%50 %%64 %%60 %%74 %%70^") do^
set $=%%!%%1:~0%%300%%!%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%^
%$:0=F%%$:0=E%%$:0=D%%$:0=C%%$:0=B%%$:0=A%%$:0=9%%$:0=8%^
%$:0=7%%$:0=6%%$:0=5%%$:0=4%%$:0=3%%$:0=2%%$:0=1%%$%^&^
for %%$ in (0%%300+0x0%%!$:~511%%#,1%%!%%!$:~255%%#,1%%!) do^
(if %%? lss ' endlocal)^&(set /A %%2=%%$^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
for %%i in (i o F $) do set "%%i="
@goto :eof
in Arbeit ....
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLen2u
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
FOR /F %%! IN ("! ! ^ ^^^^^^^^^^^!") DO set i=%%!%%1:~03777,1%%!^
x%%!%%1:~03777,1%%!x&set o=%%!%%1:~0%%4777,1%%! x%%!%%1:~0%%4777,1%%!x^
%%!%%1:~0%%4377,1%%! x%%!%%1:~0%%4377,1%%!x
set F=FEDCBA9876543210&set $=0000000000000000
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO ^
set %~1=^
@for /f %%? in ("%%! '") do @for %%. in (1 2) do if %%.==2 ^
@for /f tokens%%#=1-2 %%1 in ("%%!$args%%! len") do^
if not defined %%1 @(if %%? lss ' endlocal)^&(set /A %%2=0) else^
for /f "tokens=7,11,15,19delims= " %%4 in (^"^
%i% %i:3=7% %i:3=13% 17 13 7 3 16 12 6 2 15 11 5 1 14 10 4 0^") do^
for /f tokens%%#=15delims%%#=%%# %%3 in (^" %o:4=7% %o:4=6% %o:4=5% %o:*x =%^
%%44 %%40 %%54 %%50 %%64 %%60 %%74 %%70^") do^
set $=%%!%%1:~0%%300%%!%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%^
%$:0=F%%$:0=E%%$:0=D%%$:0=C%%$:0=B%%$:0=A%%$:0=9%%$:0=8%^
%$:0=7%%$:0=6%%$:0=5%%$:0=4%%$:0=3%%$:0=2%%$:0=1%%$%^&^
for %%$ in (0%%300+0x0%%!$:~511%%#,1%%!%%!$:~255%%#,1%%!) do^
(if %%? lss ' endlocal)^&(set /A %%2=%%$^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
for %%i in (i o F $) do @set "%%i="
@goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initStrLenAll
:: Computes the number of bytes in a string.
:: %strLen% str len
:: str - [ByRef In] Name of the variable containing the string to be measured.
:: len - [ByRef Out] Name of the variable that receives the measured length.
:: Strings of up to 8191 characters are supported.
@FOR /F %%! IN ("! ! ^ ^^^^^^^^^^^!") DO @set i=%%!%%1:~03777,1%%!^
x%%!%%1:~03777,1%%!x&set o=%%!%%1:~0%%4777,1%%! x%%!%%1:~0%%4777,1%%!x^
%%!%%1:~0%%4377,1%%! x%%!%%1:~0%%4377,1%%!x
@set F=FEDCBA9876543210&set $=0000000000000000
%== ! -> exclamation mark, # -> caret ==% @FOR /F "tokens=1-3" %%! IN (
"! ! ^ ^^^! . ^^^^") DO @^
set strLen=^
@for /f %%? in ("%%! '") do @for %%. in (1 2) do @if %%.==2 ^
@for /f tokens%%#=1-2 %%1 in ("%%!$args%%! len") do^
@if not defined %%1 (if %%? lss ' endlocal)^&(set /A %%2=0) else^
for /f "tokens=7,11,15,19delims= " %%4 in (^"^
%i% %i:3=7% %i:3=13% 17 13 7 3 16 12 6 2 15 11 5 1 14 10 4 0^") do^
@for /f tokens%%#=15delims%%#=%%# %%3 in (^" %o:4=7% %o:4=6% %o:4=5% %o:*x =%^
%%44 %%40 %%54 %%50 %%64 %%60 %%74 %%70^") do^
@set $=%%!%%1:~0%%300%%!%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%%F%^
%$:0=F%%$:0=E%%$:0=D%%$:0=C%%$:0=B%%$:0=A%%$:0=9%%$:0=8%^
%$:0=7%%$:0=6%%$:0=5%%$:0=4%%$:0=3%%$:0=2%%$:0=1%%$%^&^
for %%$ in (0%%300+0x0%%!$:~511%%#,1%%!%%!$:~255%%#,1%%!) do^
@(if %%? lss ' endlocal)^&(set /A %%2=%%$^
) else (if %%? GTR ' setlocal enabledelayedexpansion)^&set $args=
@for %%i in (i o F $) do @set "%%i="
@goto :eof
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:initTimediff
::: 32 characters shortened
FOR /F "tokens=1-3" %%! IN ("! ! ^ ^^^! . ^^^^") DO %== ! -> exclamation mark, # -> caret ==%^
set timediff=for /f %%? in ("%%! '") do for /l %%0 in (1 1 2) do if %%0 equ 2 (for /f "tokens=1-3" %%- in ("%%!_i_%%!") do set _t1_=%%!%%-:%%# =0%%!^&set _t2_=%%!%%.:%%# =0%%!^&^
set /a "_d_=(8640000+(((1%%!_t2_:~,2%%!*60+1%%!_t2_:~3,2%%!)*60+1%%!_t2_:~6,2%%!)*100+1%%!_t2_:~-2%%!-36610100)-(((1%%!_t1_:~,2%%!*60+1%%!_t1_:~3,2%%!)*60+1%%!_t1_:~6,2%%!)*100+1%%!_t1_:~-2%%!-36610100))%%8640000,_o_=100000000+(_d_%%100),_d_/=100,_o_+=(_d_%%60)*100,_d_/=60,_o_+=(_d_%%60)*10000+_d_/60*1000000"^&^
for %%' in (%%!_o_:~1%%#,2%%!:%%!_o_:~3%%#,2%%!:%%!_o_:~5%%#,2%%!.%%!_o_:~-2%%!) do (if %%? lss ' endlocal)^&if %%! equ %%/ (echo %%') else set %%/=%%') else (if %%? GTR ' setlocal enabledelayedexpansion)^&set _i_=
goto :eof