I have an array in a batch file where I would like to get in each iteration the i
element and i+1
(called in my batch serialNumberSection
), starting from the second position of the input. So far, I have been able to get the i
elements but I cannot do the same with the i+1
and I don't understand why.
What am I doing wrong?
input array = [0x33333 0xAA 0x33323130 0xBB 0x37363534 0xCC
0x42413938 0xDD 0x46454443]
My code
set argCount=0
for %%x in (%*) do (
set /A argCount+=1
set "argVec[!argCount!]=%%~x"
)
echo Number of processed arguments: %argCount%
set serialNumberSection=2
for /L %%i in (2,2,%argCount%) do (
echo %%i- "!argVec[%%i]!"
set /A serialNumberSection+=1
echo %%serialNumberSection !argVec[%%serialNumberSection]!
)
My output
Number of processed arguments: 9
2- "0xAA"
%serialNumberSection <=Expected: 0x33323130
4- "0xBB"
%serialNumberSection <=Expected: 0x37363534
6- "0xCC"
%serialNumberSection <=Expected: 0x42413938
8- "0xDD"
%serialNumberSection <=Expected: 0x46454443