Echo batch file arrays using a variable for the index?

后端 未结 3 1996
陌清茗
陌清茗 2020-12-20 23:42

If I have a batch file and I am setting arrays with an index that is a variable

@echo off
SET x=1
SET myVar[%x%]=happy

How do I echo that t

3条回答
  •  太阳男子
    2020-12-21 00:32

    one way you can do this is to use

    call echo %%myVar[%x%]%%
    

    call lets you put variables in places where they wouldn't normally work, if you use the double percents

提交回复
热议问题