Batch file 批处理文件变量三明治

Batch file 批处理文件变量三明治,batch-file,nested,Batch File,Nested,我做了这批 @echo off :U set /a x=%x%+1 set /p var%x%=What is your data point (end to begin) if %var%x%%==end ( SEt /a x=%x%-1 goto New ) goto U :next 它才刚刚开始,主要的问题是完全不同的(我不会说,所以你不会回答),正如你可能猜到的,我需要一种在变量中包含一个变量的方法(我想这叫做嵌套,但我可能错了)你需要延迟扩展 @echo off setlocal e

我做了这批

@echo off
:U
set /a x=%x%+1
set /p var%x%=What is your data point (end to begin)
if %var%x%%==end (
SEt /a x=%x%-1
goto New
)
goto U
:next

它才刚刚开始,主要的问题是完全不同的(我不会说,所以你不会回答),正如你可能猜到的,我需要一种在变量中包含一个变量的方法(我想这叫做嵌套,但我可能错了)

你需要延迟扩展

@echo off
setlocal enableDelayedExpansion
:U
set /a x+=1
set /p var%x%=What is your data point (end to begin)
if !var%x%!==end (
  set /a x-=1
  goto New
)
goto U
:next
注意-我简化了你的数学表达式。SET/A表达式中的变量不需要用百分比括起来,
x+=1
x=x+1
相同


您的
转到新的
:下一个
标签不匹配-可能有问题,可能是故意的。

这通常用于管理向量或值数组。看见