computing
  • 0

Recall a Batch Array Using a Variable

  • 0

I have used the following code to create a Batch Array.

Set /A Count=1
:LOOP
SET Temp[%Count%]=A
SET /A Count+=1
IF %Count%==10 (GOTO EOF) ELSE GOTO LOOP

——————————————————————-

Command Line: ECHO %Temp[1]%
Output = A

Although what I want to do is to use a variable in place of the “1” in “Temp[1]”

That way I can recall the entire array again
similar to how I originally created it using a Loop and Counter.

1 – Set /A Count=1
2 – :LOOP
3 – ECHO %Temp[%Count%]%
4 – IF %Count%==10 (GOTO EOF) ELSE GOTO LOOP

——————————————————————-

Line 3: Is where I have the problem. I don’t know the correct code/syntax to be able to output the data stored in the array.

The code will only output the name of the array. Any Suggestions?

Share