Link to home
Start Free TrialLog in
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
)
Avatar of NVIT
NVIT
Flag of United States of America image

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

@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

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?
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No feedback from OP