i have a batch file. i want to print all the values but it also displays the last value of for loop.

i have enter 3 tasks but it only displays last task. how i can display all the tasks.
@echo off
echo Enter Your Tasks::
setlocal enabledelayedexpansion
for /L %%a in (1 1 3) do (
set /p xx= %%a
)
meet sidhuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
Not sure what you're trying to do but, what you have doesn't display any value of XX. Not even the last, as you say.
This displays each value:
@echo off
setlocal enabledelayedexpansion
echo Enter Your Tasks::
for /L %%a in (1 1 3) do (
  set /p xx= %%a
  echo !xx!
)

Open in new window

0
Shaun VermaakTechnical Specialist/DeveloperCommented:
@echo off
setlocal enabledelayedexpansion
echo Enter Your Tasks::

set maxTasks=3
for /L %%a in (1 1 %maxTasks%) do (
  IF %%a NEQ %maxTasks% (set /p xx= %%a)
)

Open in new window

0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Shaun, that will display 2 prompts only. No clue how that is related to what the OP asked for?

Meet, I'm confused as the other Experts. The batch file asks for 3 "tasks", displaying a prompt for each with visual feedback about the input. So what is missing?
0
Bill PrewCommented:
If you are looking for a way of capturing 3 entries for three different tasks, then you could assign each to a different variable and use them.  Here's one approach to that, creating variables named with the task number in their name.  There are other approaches that could be used, but thought this might give you some ideas.

@echo off
setlocal EnableDelayedExpansion

echo Enter Your Tasks:

for /L %%a in (1 1 3) do (
  set /p "Task[%%a]=Task %%a: "
)

echo %Task[1]%
echo %Task[2]%
echo %Task[3]%

Open in new window

~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shaun VermaakTechnical Specialist/DeveloperCommented:
No feedback from OP
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.