Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
for /f "delims=," %%A in (stats.bat) do ( set health=%%A set strength=%%B ...)
echo %health%,%strength%,...>stats.bat
and to reply to Geek-9pm i have never even heard of WSH and most of the game is already created im just working on loading/saving the game now, thanks for the tip though ill be looking it up
Windows Script HostFrom Wikipedia, the free encyclopedia (Redirected from WSH)http://en.wikipedia.org/wiki/WSHThe Microsoft Windows Script Host (WSH) is an automation technology for Microsoft Windows operating systems that provides scripting capabilities comparable to batch files, but with a greater range of supported features. It was originally called Windows Scripting Host, but was renamed for the second release.
strength=25health=100intellect=50
@echo offREM Reading in Property filefor /f "tokens=1,2 delims==" %%G in (settings.ini) do set %%G=%%HREM echoing the valuesecho Strength %strength%echo Health %health%echo Intellect %intellect%REM Changing the values of eachset /a strength+=10set /a health-=5set /a intellect-=8REM echoing the changed valuesecho Strength %strength%echo Health %health%echo Intellect %intellect%REM Writing the changes back to the settings filefor %%I in (strength health intellect) do ( setlocal enabledelayedexpansion type settings.ini | find /v "%%I=">settings.tmp move /y settings.tmp settings.ini >nul echo %%I=!%%I!>>settings.ini)type settings.ini
Strength 25Health 100Intellect 50Strength 35Health 95Intellect 42strength=35health=95intellect=42
strength=25 health=100 intellect=50
@echo offREM Read settings from filefor /f %%S in (settings.ini) do set %%SREM Show values stored in memoryecho strength %strength%echo health %health%echo intellect %intellect% REM Alter a settingset /p health="Enter new value for health ? "REM Write settings to fileecho strength=%strength% > settings.iniecho health=%health% >> settings.iniecho intellect=%intellect% >> settings.ini
MyVarStrength=100MyVarHealth=50MyVarIntellect=65
@echo offREM Read settings from filefor /f %%S in (settings.ini) do set %%SREM Show settings now stored in memoryecho strength %MyVarStrength%echo health %MyVarHealth%echo intellect %MyVarIntellect% REM alter a setting in memoryset /p MyVarHealth="Enter new value for health ? "REM Write settings to fileset MyVar > settings.ini
MyVarHealth=67MyVarIntellect=65MyVarStrength=100
MyProgramVarRuncounter=1MyProgramVarLastRun=First run
@echo offREM Read values from filefor /f "tokens=*" %%S in (Runcount.log) do set %%Secho Script has been run %MyProgramVarRuncounter% time(s) Last run date/time %MyProgramVarLastRun%REM increment counterset /a MyProgramVarRuncounter+=1REM Get date and time into variableset MyProgramVarLastRun=%date% %time%REM Write new values to fileset MyProgramVar > Runcount.log
C:\>Lastrundemo.batScript has been run 1 time(s) Last run date/time First runC:\>Lastrundemo.batScript has been run 2 time(s) Last run date/time 22/01/2012 14:20:15.86C:\>Lastrundemo.batScript has been run 3 time(s) Last run date/time 22/01/2012 14:20:20.61C:\>Lastrundemo.batScript has been run 4 time(s) Last run date/time 22/01/2012 14:20:27.77C:\>Lastrundemo.batScript has been run 5 time(s) Last run date/time 22/01/2012 14:20:30.14C:\>Lastrundemo.batScript has been run 6 time(s) Last run date/time 22/01/2012 14:20:41.33C:\>Lastrundemo.batScript has been run 7 time(s) Last run date/time 22/01/2012 14:22:14.76
Thanks for the reply squash, but I need the stats to be overwritten rather than flooding the file with updated ones. Any idea how I could change your code to achieve this? Thanks.
You obviously didn't run my code. If you look at the output you will see after changing the values and rewriting the values to the stats file that the only values back in the file are the original value names with updated stats numbers. I don't know what you are thinking it is doing.
Ahhh, I thought by "output" you meant what would be in the file after the code had run, my apologies and thank you again, Ill have a look into all suggestions and see what code fits best then.