0

I have encounter a problem in getting array value, the following is my code snippets:

setlocal enabledelayedexpansion
set arraynum=0
set count=0
set list[0]=1
For /R %cd%\ %%G IN (*) do (
set filenum=%%G
echo %%G
set list[!arraynum!]=!filenum!
set /a arraynum+=1
)

echo %arraynum%
echo %list%
echo %count%
echo %%list[%count%]%%
pause

the result value of %%list[%count%]%% is %list[0]%, not the value of filename, it's very strange and is there any way or any instruction to cover that, thanks a lot.

1

1 Answer 1

1

Since you already have delayed expansion enabled, you can use it to get the array value.

echo !list[%count%]!

If you didn't have it enabled, you could have used call instead.

call echo %%list[%count%]%%
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.