【发布时间】:2017-05-25 20:57:39
【问题描述】:
您好,这个批处理脚本有问题,它不起作用:
set OUTdir=../output
@echo on
:: ex nFun tol M Nt print
:: nFun: numero di funzione test [1,...,7]
:: tol: error tolerance
:: M: ridotta di ordine 2*M+1
:: Nt: Numero di valori della funzione inversa
:: print: 1 (to print the header) 2(to print the end of the header) 0 or nothing( to print just output values)
SET /A y=1
set /A max=16384
FOR /L %%x IN (32,1,%max%) DO (
IF %y% EQU 1 (
ex 1 1e-9 %%x 25 %y% > %OUTdir%\out_F01_times_9.txt
set /A y=0)
ELSE (
if %y% EQU 0 if %%x LSS %max% (
ex 1 1e-9 %%x 25 0 > %OUTdir%\out_F01_times_9.txt )
ELSE (
ex 1 1e-9 %%x 25 2 > %OUTdir%\out_F01_times_9.txt ) )
)
ex 是一个程序,其他数字是命令行参数。
你能帮帮我吗?我正在尝试创建一个批处理来执行具有不同参数的 ex 程序。
错误是ELSE IS NOT RECOGNIZED AS外部或内部命令
【问题讨论】:
-
也许this 可以提供帮助
-
好的。但似乎 y 变量没有更新
-
您需要启用并应用delayed expansion,因为您正在编写和在同一个带括号的代码块中读取变量...
-
SET /A用于算术运算,不设置数值变量。你可以使用SET "y=1"set "max=16384"和set "y=0"。 -
我从来没有说过它是无效的,我完全知道它的优点和缺点。在脚本的上下文和结构中,OP 不需要帮助和建议。
标签: windows batch-file