Tom Lenc
Tom Lenc

Reputation: 765

Adding number 1 to a variable everytime the command executes

I want to make a code that would extend a variable in a batch file. I have this code:

@echo OFF
color A
echo press Enter
pause >nul
:again
cls
set /a sum1=+1
echo press Enter(pressed %NUM% times)
cls
goto again

I want to extend the variable by 1, everytime the commands executes. So the output should look like this(An example):

press Enter(pressed 3 times)

Any ideas? Excuse my english..

Upvotes: 0

Views: 1746

Answers (1)

Stephan
Stephan

Reputation: 56180

the correct syntax is:

set /a sum1+=1

Upvotes: 2

Related Questions