-1
FOR /L %%A IN (1,1,10) DO (
SET /P INPUT%%A= ENTER THE FIRST INPUT :
ECHO %INPUT%%A% )

:: Here is my problem i dont know how to get a value in variable INPUT%%A

Ps Sarvna
  • 1
  • 4
  • You're looking for [how to create an array in batch](https://stackoverflow.com/questions/17605767/create-list-or-arrays-in-windows-batch). Specifically, look at Aacini's answer. – SomethingDark Sep 02 '18 at 03:48
  • To `Echo` it in the loop, _(which seems absolutely unnecessary in this case)_, you'll need either a pseudo `Call`: `CALL ECHO %%INPUT%%A%%`, or to have previously enabled delayed expansion: `SETLOCAL ENABLEDELAYEDEXPANSION`, before using `ECHO !INPUT%%A!`. You should also change the wording, the use of `FIRST` would only be appropriate once! – Compo Sep 02 '18 at 07:59

1 Answers1

0

All you need is delayedexpansion. From cmd console run setlocal /? for help on it. As an example, if you want to set a standard variable name of !output!, but change the content of it to include the number of the loop counter:

@echo off
setlocal enabledelayedexpansion
for /L %%i in (1,1,10) do (
  if %%i equ 1 set handle=st
  if %%i equ 2 set handle=nd
  if %%i equ 3 set handle=rd
  if %%i geq 4 (if %%i lss 11 set handle=th)
  set /p "input=What is your %%I!handle! input? :"
  set input=!input!%%i
  echo !input!
)

You also do not want to echo 1st each time you call the input, the 2nd is not 1st, so see the if statements examples.

Gerhard
  • 22,678
  • 7
  • 27
  • 43