检索从.txt错误的变量;批量 [英] Retrieving variables from .txt error; Batch
问题描述
:LoadSelect1
set /p Name=Enter character to load:
cls
if EXIST "%Name%_Savefile.txt" goto Load
goto LoadError
:Load
for /f "tokens=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26" %%a in (%Name%_Savefile.txt) do call :Process %%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z
goto Stats
:Process
set Location=%1
set Name=%2
set Gender=%3
set Age=%4
set Gold=%5
set Hunger=%6
set Illness=%7
set Wounds=%8
set CHP=%9
set MHP=%10
set CMP=%11
set MMP=%12
set DMG=%13
set DFN=%14
set INT=%15
set DEX=%16
set STR=%17
set Head=%18
set Shoulder=%19
set Neck=%20
set Chest=%21
set Glove=%22
set Leg=%23
set Feet=%24
set LTWP=%25
set RTWP=%26
以上code是用来检索我的批处理脚本保存至文本文件中的变量。变量保存细到各条线。当呼叫:使用过程中的作用,1%施加%1,和%1X变成1%附加号码。与此同时%2-9是空白的,并%2X是用空格连接数。解决方案将是巨大的。
Above code is used to retrieve variables saved to a .txt file in my batch script. Variables save fine to individual lines. When Call :Process function is used, %1 is applied for %1, and "%1X" become %1 with number attached. Meanwhile %2-9 are blank, and %2X are blanks with number attached. Solution would be great.
满code 的引擎收录
要重现:运行批处理文件。通过提示去,直到9选择部分。键入保存。关闭并重新打开。去加载选项。键入从previous名。查看错误。
To recreate: Run as batch file. Go through prompts until section with 9 choices. Type "Save". Close and reopen. Go to Load option. Type in name from previous. View errors.
推荐答案
这将如果保存会更容易的 savefile.txt
格式为:
It would be easier if you save your savefile.txt
in this format :
savefile.txt
savefile.txt
Location=AAAA
Name=BBBB
Gender=CCCC
Age=DDDD
Gold=EEEE
Hunger=FFFF
Illness=GGGG
Wounds=HHHH
,然后设置保存在savefile.txt变量:
and then to set the variables saved in savefile.txt :
for /f "delims=" %%a in (savefile.txt) do set %%a
您还可以保存你的 saveFile的
为的.bat
那么它会是这样的:
You can also save your savefile
as .bat
then it will look like this :
set Location=AAAA
set Name=BBBB
----
和使用电话:savefile.bat
所有瓦尔将评估
这篇关于检索从.txt错误的变量;批量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!