我的for循环输出有问题。下面的每个变量中有35个元素,但是当我运行脚本时,它只输出31行然后停止。对于我的生活,我无法弄清楚如何解决它。
有人有什么建议吗?提前致谢
脚本:
@ECHO off
ECHO LINE 1 > test.txt
SET VAR1=[01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35]
SET VAR2=5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175
SET numVar=1
For %%A in (%VAR1%) DO (
call :forLoop2
)
TYPE test.txt
PAUSE
EXIT
:forLoop2
For /F "tokens=%numVar%" %%B in ("%VAR2%") DO (
SET /a numVar=%numVar%+1
ECHO %%A INTO %%B >> test.txt
EXIT /b
)
输出:
LINE 1
[01] INTO 5
[02] INTO 10
[03] INTO 15
[04] INTO 20
[05] INTO 25
[06] INTO 30
[07] INTO 35
[08] INTO 40
[09] INTO 45
[10] INTO 50
[11] INTO 55
[12] INTO 60
[13] INTO 65
[14] INTO 70
[15] INTO 75
[16] INTO 80
[17] INTO 85
[18] INTO 90
[19] INTO 95
[20] INTO 100
[21] INTO 105
[22] INTO 110
[23] INTO 115
[24] INTO 120
[25] INTO 125
[26] INTO 130
[27] INTO 135
[28] INTO 140
[29] INTO 145
[30] INTO 150
[31] INTO 155