OK, here goes...
I'm building a batch file with a menu that is set dynamically according to settings in multiple ini files, I used a script suggested to me in a previous question here.
Now, I need to add user input that export the selected menu option to another variable, in normal menu, that is not set dynamically it's easy enough, I've done it many times but I can't figure out how to do so in this instance.
Here's my current script:
@echo off
setlocal EnableDelayedExpansion
:LangMenu
for /L %%D in (1,1,20) do (
if exist Common\Settings\Data%%D.ini for /F "eol=# tokens=1,2 delims==" %%a in (Common\Settings\Data%%D.ini) do (
set line=%%a
if "!line:~2,5!" neq "clude" (
REM Define "normal" variables, i.e. Compressor, Method, etc.
set %%a=%%b
) else if "!line:~7!" neq "" (
REM Define the base array elements, i.e. D1IncludeAR=%%b, D1ExcludeAR=%%b, ...
set D%%D%%a=%%b
REM Set Show?? array elements with value equal 1, i.e. ShowAR=1, ...
REM when anyone of DiInclude?? or DiExclude?? corresponding elements was given
if defined D%%D%%a set Show!line:~7!=1
)
)
)
:LangContinue
REM Define a list of language abbreviations, i.e. "langs=AR CZ DE ..."
REM and the corresponding language names array, i.e. lang[AR]=Arabic, ...
REM At same time, calculate original OptNum
for %%a in ("AR=Arabic" "CZ=Czech" "DE=German" "EN=English" "ES=Spanish" "ESMX=Spanish (Mexico)"
"FR=French" "HU=Hungarian" "IT=Italian" "JP=Japanese" "KR=Korean" "PL=Polish"
"PR=Portuguese" "PRBR=Portuguese (Brazil)" "RU=Russian" "ZH=Chinese") do (
for /F "tokens=1,2 delims==" %%b in (%%a) do (
set "langs=!langs! %%b"
set "lang[%%b]=%%c"
set /A "OptNum+=Show%%b"
)
)
:LangSelect
cls
REM Show the language menu
set #=0
for %%a in (%langs%) do (
if defined Show%%a (
set /a #+=1
echo [!#!] !lang[%%a]!
)
)
set /p SelectLang=Please Choose The Language You Want:
if not "%SelectLang%"=="" Goto LangSet
if "%SelectLang%"=="" goto LangError
:LangError
cls
Echo ERROR: No Language Selected!!
pause
goto LangSelect
:LangSet
if "%SelectLang%"=="1" set LangIs=1
echo Selected Language = %LangIs%
Please note: I just put 1 in the set LangIs for the time being so I won't get echo is off message, it's not at all what I need, just a placeholder.
What I need is to set LangIs variable to the picked option...
An example: Menu output is this:
[1] Arabic
[2] German
[3] English
[4] Spanish
[5] Italian
Please choose the language you want:
The variable language in the above example can be any languages, even up to 16 languages can be listed, the numbers are set dynamically so if available languages where different 5 languages it was still 1-5.
I need a way that the numbered choice entered by the user will write a variable with the Language name shown by it, so, for example, if the user type 5, I need a variable, that will have either "Arabic" or "AR" in it.
so, for example, if I use the echo command to show the choice it should output something like this if the number 1 is selected (in above menu example):
Selected Language = AR
or
Selected Language = Arabic
Or whatever language is assigned to the number 1 in the menu.
This variable, will have to be checked later on in my script up to 20 different times to check what language is selected in order to set another variable according to the selected language.
Any suggestions will be much appreciated.