我想创建一个在其参数中使用用户输入变量的for循环。这就是我所拥有的:
@ECHO off
DEL "./positions.txt"
SET /P start_position= Please enter the start position:
SET /P end_position= Please enter the end position:
SET /P step_size= Please enter the step size:
FOR /L %%A IN (%start_position%,%end_position%,%step_size%) DO (
ECHO %%A >> positions.txt
)
ECHO( & echo.Done! "positions.txt" was generated. & echo.
pause
然而,这似乎并不奏效。以下是我在输出中得到的结果:
>> Done! "positions.txt" was generated.
它运行,但跳过for循环。有什么问题?
答案 0 :(得分:3)
for /L
循环使用订单开始,步骤,结束。
FOR /L %%A IN (%start_position%,%step_size%,%end_position%) DO (
ECHO %%A >> positions.txt
)