所以我在考虑这个,这应该像一个会说话的模拟器,如果你写下批处理文件不知道的东西,它会要求你写下该问题的答案,稍后创建一个文本文件使用问题名称,以及带有答案的文本文件中的一行。唯一的问题是,我不知道如何使批处理文件读取文本文件中的行。请帮忙。
@echo off
echo Hello!
echo Talk To Me!
pause>nul
:1
cls
echo Enter text
set /p talk=
if exist %talk% (
goto answer
) else (
goto dontknow
)
:answer
*finds string in txt file and writes it here*
pause>nul
goto 1
:dontknow
echo I dont know that yet. Teach me what to answer
set /p teach=
echo %teach% >> %talk%.txt
pause>nul
goto 1
答案 0 :(得分:0)
读取.txt文件并将其显示为批处理文件。使用type命令。在您的情况下type %talk%
已编辑(次要)您的代码。
@echo off
echo Hello!
echo Talk To Me!
pause>nul
:1
cls
echo Enter text
set /p talk=
if exist %~dp0%talk%.txt (
type %talk%.txt
pause>nul
goto 1
) else (
goto dontknow
)
:dontknow
echo I dont know that yet. Teach me what to answer
set /p teach=
echo %teach% >> %talk%.txt
pause>nul
goto 1