batch loop variable

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
gjvisser
Posts: 1
Joined: 11 Dec 2010 10:48

batch loop variable

#1 Post by gjvisser » 11 Dec 2010 10:52

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: batch loop variable

#2 Post by !k » 11 Dec 2010 12:30

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


Post Reply