我正在尝试用批量制作一个简单的问题游戏。像这样:
------- This is Ascii --------
1. This is First Question
a. this is option a
b. this is option b
c. this is option c
d. this is option d
Put Your Answer > [a/b/c/d]
我想要的是:
我希望我的游戏能够从文本文件加载问题,因为问题非常多
这是我的Question.txt文件示例:
1. This is First Question
a. This is option a
b. This is option b
c. This is option c
d. This is option d
2. This is Second Question
a. This is option a
b. This is option b
c. This is option c
d. This is option d
3. This is Third Question
a. This is option a
b. This is option b
c. This is option c
d. This is option d
我正在尝试使用FOR命令等...而且我没有弄清楚主菜单和其他东西,我得到了自己的东西。我的问题只有这个。 你能帮我解决一下吗?
答案 0 :(得分:0)
这使用了来自 - https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat
的名为findrepl.bat
的帮助程序批处理文件
将findrepl.bat
放在与批处理文件相同的文件夹中或路径上。
确保您的question.txt
底部有一个空行,然后尝试:
@echo off
for /L %%a in (1,1,3) do (
echo.
type "question.txt" | findrepl "^%%a. " /e:"^$"
pause
)
使用此代码的另一种方法是这样的
type "question.txt" | findrepl "^1. " /e:"^$"
pause
type "question.txt" | findrepl "^2. " /e:"^$"
pause
type "question.txt" | findrepl "^3. " /e:"^$"
pause
type "question.txt" | findrepl "^4. " /e:"^$"
pause