Avatar of meet sidhu
meet sidhu
 asked on

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
)
Windows Batch

Avatar of undefined
Last Comment
Shaun Vermaak

8/22/2022 - Mon
NVIT

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

Shaun Vermaak

@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

Qlemo

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?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Bill Prew

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Shaun Vermaak

No feedback from OP