I have stripped my problematic code down to the problematic lines. Why the first echo works and the second one does not work?
setlocal enabledelayedexpansion
set /a r=19
set blocks=MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
for /L %%a in (-%r%,1,%r%) do (
set /a w2=r
:: This works
set line=!blocks:~0,%r%!
echo( !line!
::This does'nt work
set line=!blocks:~0,!w2!!
echo( !line!
)
exit /b
EDITED: I have kept on trying and this line works:
call set line=%%blocks:~0,!w2!%%
Now the question is : could someone please explain to me WHY I must use call?