Storing strings in other batch files, Deleting and renaming.

March 2, 2012 at 16:20:40
Specs: Windows Vista
So I am creating a batch rpg. Now I want to set strings for things like everything in your inventory, your info (race age class name gender) and I want it all stored in different batch files but still accesible from the main batch file. The following code is just a sample from the program: I am using hyphons (-) to show you all the separation in files. They are not actually in the code.
------------------------------------------
set string5100=Clothes
call inventory.bat
------------------------------------------
:inventory
cls
echo %string5100%
pause
-----------------------------------------

So code from the first section is in my main batch file, so it sets the string as 'Clothes'. Now how do i make it so String5100 will also be 'Clothes' in other batch files. And is there any way for me to delete or change the name of strings from the main batch file in other batch files. One of the options within my game is to check inventory. I want to be able to call my inventory.bat and have it list everything that was set in the main file. And be able to manually delete the strings or items inside the inventory.bat and have it take effect in the main batch file as well.


See More: Storing strings in other batch files, Deleting and renaming.

Report •

#1
March 3, 2012 at 05:32:20
I would create .txt files to store some of this stuff. Then you can just read in from the file and remove what you want. By manually do you mean opening the file and removing inventory by using the delete key, or from within the main batch file.

If you use .txt files then you wouldn't have to define the inventory from within the batch file, it would remain stored. perhaps in a folder with the players name attached to it. Then within that folder you could have the players stats(race age class name gender) within one .txt file and then the inventory within another.

mike


Report •

#2
March 3, 2012 at 06:08:47
//contents of batch
@ECHO OFF
FOR /F "tokens=1-4 delims= " %%G IN (c:\player1\stats.txt) DO echo [PLAYER NAME %%G ] [CURRENT AGE %%H] [RACE %%I] && ECHO. && ECHO [PLAYERNAME %%J]

pause


//contents of stats.txt
elf 18 ranger HDInfinity

mike


Report •
Related Solutions


Ask Question