0

As in the question I am having trouble finding a good answer on how to extract values from a txt file into multiple variables, my plan for this is to incorporate saving into the game I mentioned in my previous question(I already have the values saving into the file I just need to be able to receive them back)

 @echo off
    set User=DNABuster
    set /a Round=1
    for /f "tokens=* delims=" %%x in (Save%User%.txt) do (
    set a=%%x %0
    set b=%%x %1
    set c=%%x %2
    set d=%%x %3
    )

Is my current code(%0 is just a placeholder until I figure out how to get the first value alone to be equivalent to that variable), I also tried:

set User=DNABuster
set /a Round=1
set test=0
for /f "tokens=* delims=" %%x in (Save%User%.txt) do (
set /a test=%test%+1
set a.%test%=%%x
)
DNABuster
  • 3
  • 3
  • See [here](https://stackoverflow.com/questions/65377330/is-there-a-way-to-make-a-checkpoint-system-in-batch-files/65378487#65378487) for a simple save load method – T3RR0R May 23 '22 at 14:11
  • thx I actually used the answer above the suggested one @T3RROR – DNABuster May 23 '22 at 16:56

1 Answers1

0

This answer I saw above a suggested answer was perfect for my problem: Reserve a character (say, #) to be used as the first character of all of the variables you want to record.

so...

set #points=35
set action=3
set #money=22

To save all of the # variables, use

set #>filename

which would save #money and #points, but not action

To reload use

for /f "delims=" %%a in (filename) do set "%%a"

which will reload all of the variables saved in the file - which are, of course, only #variables. credit to Magoo for the post(I just copy pasted it to here for ease of access for new users)

DNABuster
  • 3
  • 3