0

So I have my word batch game I'm working on in Windows 7. I'm going to implement a scoring system into it but I first must know how to actually do one. So after an easy level is completed I want it to add 25 points to a point counter. Then at a menu, it states how much points I have. That might seem easy BUT here's the thing: I want it too save how much points I have. I have a folder which, after every level is completed, it makes a Level completed file with the dir > command. Of course, as well I have a thing which says if EXIST (Level Completed File), goto (Other Level). So, as I was saying, It would be preferable for the points to be saved the same way. I thought at first, to do it I have to get a dir > points to write in the file '25', then I have a check command to extract the 25 from that file and increment another 25 if a level has been completed and save it again as points.

I might be over-complicating the situation, but I hope you can take the time to figure out what I mean, and how to solve this, for then I could use this many times as a solid points system. Thanks. (Note: I check my posts everyday)

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
user2507295
  • 159
  • 1
  • 2
  • 6

1 Answers1

1

Is this what you are looking for?

@ECHO OFF &SETLOCAL
SET "scorelist=myscore.txt"

IF NOT EXIST %scorelist% (
    SET /A SCORE=0
) ELSE (
    FOR /F "usebackq delims=" %%a IN ("%scorelist%") DO SET "SCORE=%%a"
)

:LOOP
SET /A SCORE=%SCORE% + 1
ECHO %SCORE%
ECHO %SCORE% > %scorelist%
PAUSE
GOTO LOOP

What I put inside the loop was of course just to display that it reads the scorelist (if any), and then writes the new score to the same file.

Espen
  • 45
  • 8