我对"电话"有疑问批处理命令:
如果我有以下内容怎么办? 致电Receive.bat hi
然后在我的代码中: 请致电Receive.bat gtg
在Receive.bat I" echo"它。 它会是这样的:echo& 1(对于" hi") ,然后在:echo%2(对于" gtg")?
这就是我得到的:
@echo off
set /p Mood=:
call Receive.bat %Mood%
*Random stuff*
set /p Food=:
call receive.bat %Food%
然后在Receive.bat:
@echo off
echo %1 <-- for Mood
pause
*Random Stuff*
echo %2 <-- for Food
答案 0 :(得分:0)
如果我理解了您的要求,以下批处理文件应该可以满足您的要求。
<强> Main.bat 强>:
@echo off
set "CallCount=0"
set "Mood="
set /P "Mood=Your mood is: "
call Receive.bat "%Mood%"
rem *Random stuff*
set "Food="
set /P "Food=The food you want is: "
call Receive.bat "%Food%"
set "CallCount="
<强> Receive.bat 强>:
set /A CallCount+=1
if "CallCount"=="2" goto Call2
if not "%~1"=="" echo %~1
rem *Random Stuff*
goto :EOF
:Call2
if not "%~1"=="" echo %~1
rem Commands for second call.
替代 Receive.bat :
set /A CallCount+=1
goto Call%CallCount%
:Call1
if not "%~1"=="" echo %~1
rem *Random Stuff*
goto :EOF
:Call2
if not "%~1"=="" echo %~1
rem Commands for second call.
goto :EOF
:Call3
if not "%~1"=="" echo %~1
rem Commands for third call.
goto :EOF
:Call4
if not "%~1"=="" echo %~1
rem Commands for fourth call.
goto :EOF