I am using command prompt in windows 7.
I found this strange that variable value modified inside if clause is updated only after if clause has been completely executed.
Here is a simple example to show this.
@echo off
set /a somevar=0
set match_string="match"
:loop
echo at loop beginning - somevar is %somevar%
if %match_string% equ "match" (
set /a somevar+=1
echo somevar inside if statement after increment - %somevar%
)
echo somevar after if statement is %somevar%
pause
goto loop
How can I have updated somevar inside if statement ?
Thanks.