批量扩展嵌套变量,无延迟扩展
是否可以在不延迟扩展的情况下扩展嵌套变量?
示例:
for /L %%i in (0,1,5) do ( echo.%somevar[%%i]% )
这是我想要做的更详细的示例(我无法在此处粘贴我的整个代码)
::%1 list of keys
::%2 output variable
SETLOCAL ENABLEDELAYEDEXPANSION
::parse some files and process information. Then it is stored into somevar
ENDLOCAL & (
for /L %%i in (0,1,%somevar.count%) do (
set "%2[%somevar[%%i].key%]=%somevar[%%i].value%"
)
)
Is it possible to expand a nested variable without delayed expansion?
Example:
for /L %%i in (0,1,5) do ( echo.%somevar[%%i]% )
Here a more detailed example of what I'm trying to do (I cant paste my whole code here)
::%1 list of keys
::%2 output variable
SETLOCAL ENABLEDELAYEDEXPANSION
::parse some files and process information. Then it is stored into somevar
ENDLOCAL & (
for /L %%i in (0,1,%somevar.count%) do (
set "%2[%somevar[%%i].key%]=%somevar[%%i].value%"
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有一些想法给您,尽管我建议您使用延迟扩展,如第三个和第四个示例中所示,并且建议您使用第四个:
Here's a few ideas for you, although I would recommend that you use delayed expansion, as in the third and fourth examples, and of those, advise that you use the fourth: