none
Batch script: echo array data back using for loop RRS feed

  • Question

  • How do I echo all the values back?


    Thanks.

    @ECHO OFF SETLOCAL EnableDelayedExpansion SET i=0 FOR %%d IN ( "abc" "xyz" "123" "456" "abcdef" "123xyz" ) DO ( SET /A i=i+1 SET DATA[!i!]=%%d ) for /L %%i in (1,1,6) do ( ECHO A: %%DATA[%%i]%% ) echo X: %DATA[1]%

    A: %DATA[1]%
    A: %DATA[2]%
    A: %DATA[3]%
    A: %DATA[4]%
    A: %DATA[5]%
    A: %DATA[6]%
     X: "abc"


    Tuesday, February 25, 2020 4:22 AM

Answers

  • I did some researching.. Here's the solution:

    for /L %%i in (1,1,6) do (
    	ECHO A: !DATA[%%i]!
    )

    • Marked as answer by slick.user Tuesday, February 25, 2020 4:29 PM
    Tuesday, February 25, 2020 4:29 PM

All replies