You should transfer also empty values over the endlocal barrier, else it's not possible to erase a value.
What's about
Code: Select all
set myVar=HELLO
call :clearVar myVar
exit /b
:clearVar
setlocal
set "%1="
endlocal %1
exit /b
The solution is to move some lines
Code: Select all
set "content=!%%C!"%\n%
set "retContent=!retContent!"set !varName[%%n]!=!content!"!LF!"%\n%
if defined content ( %\n%
%= This complex block is only for replacing '!' with '^!' =%%\n%
...
set ^"content_EDE=!content_EDE:""q="!"%\n%
) ELSE set "content_EDE="%\n%
set "retContent=!retContent!set "!varName[%%n]!=!content_EDE!"!LF!"%\n%
)%\n%
)%\n%
%= Now return all variables from retContent over the barrier =%%\n%
for /F "delims=" %%V in ("!retContent!") DO (%\n%
This should solve the problem (untesteted)