setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (temp.txt) do (
set /a k+=1
set N[!k!]=%%a
)
rem set N
rem if '%N[1]%'=='' set N1=%N[1]%
set N1=%N[1]%
set N2=%N[2]%
set N3=%N[3]%
set N4=%N[4]%
pause
rem endlocal
if "%N1%"=="" set /p M1 = "give first no "
rem set m1=!M1!
rem set m1= %!M1!%
echo %M1%
setLocal EnableDelayedExpansion
if "%N2%"=="" set /p M2 = "give second no "
echo %M2%
setLocal EnableDelayedExpansion
if "%N3%"=="" set /p M3 = "give 3rd no "
echo %N4%
...........
in above code, echo %M1% and echo %M2% results to "echo is ON" instead of user input. Why this is happening?
set /p not working perhaps
Moderator: DosItHelp
Re: set /p not working perhaps
brainuee wrote:set /p M1 = "give first no "
The set instruction works as intended.
You just are not using the variabble you expect: Your variable contains a Space at the end (in quotes: you are using "M1 " instead of "M1").
So this seems to be what you want:
Code: Select all
set /p M1= "give first no "
penpen
Edit: M2 analogous.