Batch file 参数转换为另一个函数
我尝试了以下代码,但当我添加粗体行时,它失败了Batch file 参数转换为另一个函数,batch-file,Batch File,我尝试了以下代码,但当我添加粗体行时,它失败了 :Is_Error_file_empty for /f "tokens=1,3" %%x in (%TMPLog%) do ( if "%%x"=="ERROR" SET err=TRUE( **call :a %1** ) :a if %1 neq "c" ( echo echo ERROR: you had an error with copying files,please see in error.log for
:Is_Error_file_empty
for /f "tokens=1,3" %%x in (%TMPLog%) do (
if "%%x"=="ERROR" SET err=TRUE(
**call :a %1**
)
:a
if %1 neq "c" (
echo echo ERROR: you had an error with copying files,please see in error.log for details.
)
语法有一些问题 括号不平衡,放错了位置。
也许您想在
call:a%1
中使用%1
,但我看不出它来自何处。也许您想使用第二个令牌?
EXIT/b
应放在代码块之后,否则还会执行以下代码
这段代码可以作为进一步测试的基础
:Is_Error_file_empty
for /f "tokens=1,3" %%x in (%TMPLog%) do (
if "%%x"=="ERROR" (
SET err=TRUE
call :errorInfo %%y
)
)
exit /b
:errorInfo
if "%1" neq "c" (
echo echo ERROR: you had an error with copying files,please see in error.log for details.
)
exit /b
嗨,zipi,这是全部代码吗?粗体行中右括号的左括号在哪里?“它失败了”,啊哈!它失败并杀死计算机,或者它失败而不做任何事情,或者您是否收到错误消息?您将
呼叫放在哪里:a%1)
?如果我能把问题修改得更精确一点可能会有帮助。我在if语句中调用了a,但失败了,我的意思是退出CMD