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
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
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.