Batch file 批处理文件内部数据

Batch file 批处理文件内部数据,batch-file,system,internal,Batch File,System,Internal,我试图给我的记忆游戏一个高分选项,它将保存你的分数,并在你访问程序的“高分”部分时调用所有保存的分数。到目前为止,我掌握的代码如下: @echo off REM Produced by Calder Hutchins REM This is a game title Memory Game :begin set point=0 cls echo. echo Memeory Game echo ------------------ echo 1) Play echo 2) Instructions

我试图给我的记忆游戏一个高分选项,它将保存你的分数,并在你访问程序的“高分”部分时调用所有保存的分数。到目前为止,我掌握的代码如下:

@echo off
REM Produced by Calder Hutchins
REM This is a game
title Memory Game
:begin
set point=0
cls
echo.
echo Memeory Game
echo ------------------
echo 1) Play
echo 2) Instructions
echo 3) High Scores
echo ------------------
set /p pick=^>
if %pick%==1 goto one
if %pick%==2 goto two
if %pick%==3 goto three
goto begin
:one
cls
REM Determines the number
if %point% LSS 6  set /a rand=%random% %% (100 - 1 + 1)+ 1
if %point% LSS 12 if %point% GTR 5 set /a rand=%random% %% (500 - 100 + 1)+ 100
if %point% LSS 18 if %point% GTR 11 set /a rand=%random% %% (1000 - 500 + 1)+ 500
if %point% LSS 24 if %point% GTR 17 set /a rand=%random% %% (2000 - 1000 + 1)+ 1000
if %point% LSS 30 if %point% GTR 23 set /a rand=%random% %% (9000 - 1500 + 1)+ 1500
if %point% LSS 36 if %point% GTR 29 set /a rand=%random% %% (19000 - 5000 + 1)+ 5000
if %point% LSS 42 if %point% GTR 35 set /a rand=%random% %% (32000 - 10000 + 1)+ 10000
if %point% LSS 48 if %point% GTR 41 set /a rand=%random% %% (999 - 100 + 1)+ 100
if %point% LSS 48 if %point% GTR 41 set /a randtwo=%random% %% (999 - 100 + 1)+ 100
if %point% GTR 47 set /a rand=%random% %% (9999 - 1000 + 1)+ 1000
if %point% GTR 47 set /a randtwo=%random% %% (9999 - 1000 + 1)+ 1000
echo.
REM  Prints the number  
if %point% LSS 42 echo %rand% 
if %point% GTR 41 set rand=%rand%%randtwo%
if %point% GTR 41 echo %rand%
echo.
ping localhost -n 3 >nul
cls
echo.
echo.
echo.
set /p yourOption=Guess:
REM Determines correct or wrong
if %youroption%==%rand% set /a point=%point% +1 & goto one
cls
echo.
echo You scored: %point%
echo.
set /p name=Type name:
echo %name%  -  %point% >> E:\Scripts\Batch\memoryGame\score.txt
goto begin
:two
cls
echo. 
echo The objective of the game is to get as many points as possible.  To get points you must correctly retype the numbers that appear on the screen.  The numbers show for a short period of time.  As you get more points the numbers get longer!  When you have lost you will be prompted to enter your name.  You can view the highscores too!  
echo. 
pause
goto begin
:three
cls
echo.
sort E:\Scripts\Batch\memoryGame\score.txt
echo.
pause
goto begin
上面的一个只是保存到一个文件,但我希望它保存在内部,如果可能的话。我得到了一个脚本,我已经修改过,但无法在我的游戏中实现。脚本的代码是:

@echo off
for /f "tokens=1 delims=:" %%D in ('findstr /R /N "storedData" "%~f0"' ) do set end_batch=%%D
echo Make data

echo echo data entry 4^>^>"%~f0"
echo(>>"%~f0"
echo data entry ^4>>"%~f0"

echo Print Data
type "%~f0" | more +%end_batch%
exit /b 0


:storedData
有什么建议可以让它工作吗?

嗯。。 我有一个比我以前的答案更好的想法-备用数据流(仅适用于NTFS):

echo您的得分:%point%
回声。
集合/p名称=类型名称:
回显%name%-%point%>>“%~f0:分数”
开始
:两个
cls
回声。
这场比赛的目的是尽可能多地得分。要获得分数,您必须正确地重新键入屏幕上显示的数字。这些数字显示的时间很短。当你得到更多的分数时,数字会变长!当您丢失时,系统将提示您输入姓名。你也可以查看高分!
回声。
暂停
开始
字体三
cls
回声。
更多
如果%pick%==1转到一个
如果%pick%==2转到2
如果%pick%==3转到3
开始
字体一
cls
REM决定数字
如果%point%LSS 6 set/a rand=%random%%%(100-1+1)+1
如果%point%LSS 12如果%point%GTR 5套/a rand=%random%%%(500-100+1)+100
如果%point%LSS 18如果%point%GTR 11 set/a rand=%random%%%(1000-500+1)+500
如果%point%LSS 24如果%point%GTR 17 set/a rand=%random%%%(2000-1000+1)+1000
如果%point%LSS 30如果%point%GTR 23 set/a rand=%random%%%(9000-1500+1)+1500
如果%point%LSS 36如果%point%GTR 29 set/a rand=%random%%%(19000-5000+1)+5000
如果%point%LSS 42如果%point%GTR 35 set/a rand=%random%%%(32000-10000+1)+10000
如果%point%LSS 48如果%point%GTR 41 set/a rand=%random%%%(999-100+1)+100
如果%point%LSS 48如果%point%GTR 41设置/a randtwo=%random%%%(999-100+1)+100
如果%点%GTR 47套/a兰德=%random%%%(9999-1000+1)+1000
如果%point%GTR 47 set/a randtow2=%random%%%(9999-1000+1)+1000
回声。
雷姆打印号码
如果%point%LSS 42回显%rand%
如果%point%GTR 41设置rand=%rand%%randtwo%
如果%点%GTR 41回声%rand%
回声。
ping localhost-n3>nul
cls
回声。
回声。
回声。
设置/p选项=猜测:
REM判断正确与否
如果%youroption%==%rand%set/a点=%point%+1&转到一点
cls
回声。
你的得分是:%point%
回声。
集合/p名称=类型名称:
回显%name%-%point%>>“%~f0:分数”
开始
:两个
cls
回声。
这场比赛的目的是尽可能多地得分。要获得分数,您必须正确地重新键入屏幕上显示的数字。这些数字显示的时间很短。当你得到更多的分数时,数字会变长!当您丢失时,系统将提示您输入姓名。你也可以查看高分!
回声。
暂停
开始
字体三
cls
回声。
更多Hmm。。
我有一个比我以前的答案更好的想法-备用数据流(仅适用于NTFS):

echo您的得分:%point%
回声。
集合/p名称=类型名称:
回显%name%-%point%>>“%~f0:分数”
开始
:两个
cls
回声。
这场比赛的目的是尽可能多地得分。要获得分数,您必须正确地重新键入屏幕上显示的数字。这些数字显示的时间很短。当你得到更多的分数时,数字会变长!当您丢失时,系统将提示您输入姓名。你也可以查看高分!
回声。
暂停
开始
字体三
cls
回声。
更多
如果%pick%==1转到一个
如果%pick%==2转到2
如果%pick%==3转到3
开始
字体一
cls
REM决定数字
如果%point%LSS 6 set/a rand=%random%%%(100-1+1)+1
如果%point%LSS 12如果%point%GTR 5套/a rand=%random%%%(500-100+1)+100
如果%point%LSS 18如果%point%GTR 11 set/a rand=%random%%%(1000-500+1)+500
如果%point%LSS 24如果%point%GTR 17 set/a rand=%random%%%(2000-1000+1)+1000
如果%point%LSS 30如果%point%GTR 23 set/a rand=%random%%%(9000-1500+1)+1500
如果%point%LSS 36如果%point%GTR 29 set/a rand=%random%%%(19000-5000+1)+5000
如果%point%LSS 42如果%point%GTR 35 set/a rand=%random%%%(32000-10000+1)+10000
如果%point%LSS 48如果%point%GTR 41 set/a rand=%random%%%(999-100+1)+100
如果%point%LSS 48如果%point%GTR 41设置/a randtwo=%random%%%(999-100+1)+100
如果%点%GTR 47套/a兰德=%random%%%(9999-1000+1)+1000
如果%point%GTR 47 set/a randtow2=%random%%%(9999-1000+1)+1000
回声。
雷姆打印号码
如果%point%LSS 42回显%rand%
如果%point%GTR 41设置rand=%rand%%randtwo%
如果%点%GTR 41回声%rand%
回声。
ping localhost-n3>nul
cls
回声。
回声。
回声。
设置/p选项=猜测:
REM判断正确与否
如果%youroption%==%rand%set/a点=%point%+1&转到一点
cls
回声。
你的得分是:%point%
回声。
集合/p名称=类型名称:
回显%name%-%point%>>“%~f0:分数”
开始
:两个
cls
回声。
这场比赛的目的是尽可能多地得分。要获得分数,您必须正确地重新键入屏幕上显示的数字。这些数字显示的时间很短。当你得到更多的分数时,数字会变长!当您丢失时,系统将提示您输入姓名。你也可以查看高分!
回声。
暂停
开始
字体三
cls
回声。

更多下面的批处理文件完全按照您的要求执行,即它将保存您的分数,并在您访问程序的“高分”部分时调用所有保存的分数

echo You scored: %point%
echo.
set /p name=Type name:
echo %name%  -  %point% >> "%~F0"
goto begin
:two
cls
echo. 
echo The objective of the game is to get as many points as possible.  To get points you must correctly retype the numbers that appear on the screen.  The numbers show for a short period of time.  As you get more points the numbers get longer!  When you have lost you will be prompted to enter your name.  You can view the highscores too!  
echo. 
pause
goto begin
:three
cls
echo.
for /F "delims=:" %%n in ('findstr /N "^:savedScores" "%~F0"') do set n=%%n
more +%n% "%~F0" | sort
echo.
pause
goto begin
:savedScores

下面的批处理文件完全按照您的要求执行,即它将保存您的分数,并在您访问程序的“高分”部分时调用所有保存的分数

echo You scored: %point%
echo.
set /p name=Type name:
echo %name%  -  %point% >> "%~F0"
goto begin
:two
cls
echo. 
echo The objective of the game is to get as many points as possible.  To get points you must correctly retype the numbers that appear on the screen.  The numbers show for a short period of time.  As you get more points the numbers get longer!  When you have lost you will be prompted to enter your name.  You can view the highscores too!  
echo. 
pause
goto begin
:three
cls
echo.
for /F "delims=:" %%n in ('findstr /N "^:savedScores" "%~F0"') do set n=%%n
more +%n% "%~F0" | sort
echo.
pause
goto begin
:savedScores

sort E:\Scripts\Batch\memoryGame\score.txt
要对批处理文件进行排序吗?我使用了它,这样它可以将条目名称从a排序到Z。每一行都包含
echo You scored: %point%
echo.
set /p name=Type name:
echo %name%  -  %point% >> "%~F0"
goto begin
:two
cls
echo. 
echo The objective of the game is to get as many points as possible.  To get points you must correctly retype the numbers that appear on the screen.  The numbers show for a short period of time.  As you get more points the numbers get longer!  When you have lost you will be prompted to enter your name.  You can view the highscores too!  
echo. 
pause
goto begin
:three
cls
echo.
for /F "delims=:" %%n in ('findstr /N "^:savedScores" "%~F0"') do set n=%%n
more +%n% "%~F0" | sort
echo.
pause
goto begin
:savedScores