I\'m making a text game written in bat, and the game has been done, (or more, a good part of it, such as the commands, and at the stage where you can play it); however, I wa
Create the file path for the save:
`If not exist "%userprofile%\Saves" md "%userprofile%\saves"`
Assign Variable to Folder file path:
`set saveLoc="%userprofile%\saves"`
Create blank File at target Location:
`If not exist "%saveLoc%\data.sav" break>%saveLoc%\data.sav"`
Assign a variable to your file path
`set Gamesave="%saveLoc%\data.sav`
For efficient coding... Block all your data into a single variable, prefixing with a character for delims.
`set data=+%var1%+%var2%+%var3%+%var4%`
THEN TO SAVE:
`ECHO %data% >%Gamesave%`
For efficient coding... Assign a variable to For /F loop components to bookend each token you wish to retrieve...
`Set lo=For /f "usebackq tokens=`
`Set ad= delims=+" %%a IN (%Gamesave%) DO SET`
THEN TO LOAD:
`%lo%1%ad% var1=%%a`
`%lo%2%ad% var2=%%a`
`%lo%3%ad% var3=%%a`
`%lo%4%ad% var4=%%a`
This approach saves an awful lot of typing.