Arrays

suggest change

Arrays can be emulated when delayed expansion is enabled. %name% is the value of environment variable name at parse time, while !name! is the value at execution time. A for variable is still %%i in a batch (%i at the prompt), not %i%.

@echo off
setlocal EnableDelayedExpansion
for /l %%i in (1, 1, 10) do (
  set array_%%i=!random!
)

for /l %%i in (1, 1, 10) do (
  echo !array_%%i!
)

:: For each item in the array, not knowing the length
set i=1
:startloop
if not defined array_%i% goto endloop
set array_%i%=!array_%i%!_dummy_suffix
echo A%i%: !array_%i%!
set /a i+=1
goto startloop
:endloop

Links:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents