简体   繁体   中英

Batch array call by variable

i got a problem with my batch file that echo two array contents.

for /L %%i in (1,2,%n%) do (
    set /A next=%%i+1

    echo !array[%%i]!
    echo !array[%next%]!  //This doesn't work
)

Output:

_content_array
ECHO is off.

When i turn Echo on the Output is:

 _content_array
 ECHO is on.

_content_array is perfect, it works. But the 2nd call (!array[%next%]!) doesn't work, i think i just failed to call, i tried out some other calls but it never worked for me.

Thx for your time.

for /L %%i in (1,2,%n%) do (
    set /A next=%%i+1

    echo !array[%%i]!
    for %%n in (!next!) do echo !array[%%n]!
)

You may read full details about this solution at this post .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM