简体   繁体   English

通过变量批处理数组调用

[英]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: 当我打开Echo时,输出为:

 _content_array
 ECHO is on.

_content_array is perfect, it works. _content_array很完美,可以正常工作。 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. 但是第二个电话(!array [%next%]!)不起作用,我想我只是打不了电话,我尝试了其他一些电话,但对我却没有用。

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 . 您可以在这篇文章中阅读有关此解决方案的完整详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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