I'm trying to adjust a Windows batch variable within a loop using the set /p command. After the keyboard input the variable still contains the old value. I have read that the variable set via set /p has only local scope. But I do not understand what "local" really means here.
@echo off
setlocal EnableDelayedExpansion
set a=4
echo Inital A: %a%
:LoopLabel
MODE | find %a% >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
set /p "a=enter new a: "
echo a=%a%
goto LoopLabel
)
The output is:
Inital A: 4
enter new a: 5
a=4
enter new a: 6
a=5
enter new a: 7
a=6
Does anyone have an idea and can me explain why this is happening?
Many Thanks, Jonny