Page 1 of 1

batch loop variable

Posted: 11 Dec 2010 10:52
by gjvisser
I'v gotta change the variable via input for x amount of times.

@echo off
for %%counter in (1,2,3,4) do (
set input =
set /p input=Type input:%=%
echo Your input was: %input%
)

For some reason the variable doesn't change.
How can I change the variable contents

Re: batch loop variable

Posted: 11 Dec 2010 12:30
by !k

Code: Select all

@echo off
setlocal enabledelayedexpansion
title delayedexpansion on
for %%c in (1,2,3,4) do (
set input=
set /p input=Type input:%=%
echo Your input was: !input!
)
endlocal
pause

setlocal disabledelayedexpansion
title delayedexpansion off
for %%c in (1,2,3,4) do (
set input=
set /p input=Type input:%=%
call echo Your input was: %%input%%
)
endlocal
pause