0

I'm working on a batch a big batch script, I need to create a menu that show options depending on settings in multiple .ini files, I've got the code to check the ini files down and working without much of a problem but from some reason, when I try to check if a variableX is empty and if so set variableY to 0 (zero), then if variableX not empty set variableY to 1, it doesn't work, I need some help here.

For the time being I'm creating the menu in a separate batch file from my full script, so I won't destroy a working script.

This part of my menu batch file works well:

@echo off
:LangMenu
set DN=0
:DataCheck
set /a DN=%DN%+1
if exist .\Common\Settings\Data%DN%.ini for /f "tokens=1,2 delims==" %%a in (.\Common\Settings\Data%DN%.ini) do (
if %%a==Compressor set Compressor=%%b
if %%a==IncludeAR set D%DN%IncludeAR=%%b
if %%a==IncludeCZ set D%DN%IncludeCZ=%%b
if %%a==IncludeDE set D%DN%IncludeDE=%%b
if %%a==IncludeEN set D%DN%IncludeEN=%%b
if %%a==IncludeES set D%DN%IncludeES=%%b
if %%a==IncludeESMX set D%DN%IncludeESMX=%%b
if %%a==IncludeFR set D%DN%IncludeFR=%%b
if %%a==IncludeHU set D%DN%IncludeHU=%%b
if %%a==IncludeIT set D%DN%IncludeIT=%%b
if %%a==IncludeJP set D%DN%IncludeJP=%%b
if %%a==IncludeKR set D%DN%IncludeKR=%%b
if %%a==IncludePL set D%DN%IncludePL=%%b
if %%a==IncludePR set D%DN%IncludePR=%%b
if %%a==IncludePRBR set D%DN%IncludePRBR=%%b
if %%a==IncludeRU set D%DN%IncludeRU=%%b
if %%a==IncludeZH set D%DN%IncludeZH=%%b
if %%a==ExcludeAR set D%DN%ExcludeAR=%%b
if %%a==ExcludeCZ set D%DN%ExcludeCZ=%%b
if %%a==ExcludeDE set D%DN%ExcludeDE=%%b
if %%a==ExcludeEN set D%DN%ExcludeEN=%%b
if %%a==ExcludeES set D%DN%ExcludeES=%%b
if %%a==ExcludeESMX set D%DN%ExcludeESMX=%%b
if %%a==ExcludeFR set D%DN%ExcludeFR=%%b
if %%a==ExcludeHU set D%DN%ExcludeHU=%%b
if %%a==ExcludeIT set D%DN%ExcludeIT=%%b
if %%a==ExcludeJP set D%DN%ExcludeJP=%%b
if %%a==ExcludeKR set D%DN%ExcludeKR=%%b
if %%a==ExcludePL set D%DN%ExcludePL=%%b
if %%a==ExcludePR set D%DN%ExcludePR=%%b
if %%a==ExcludePRBR set D%DN%ExcludePRBR=%%b
if %%a==ExcludeRU set D%DN%ExcludeRU=%%b
if %%a==ExcludeZH set D%DN%ExcludeZH=%%b

)

goto :CheckLoop

:CheckLoop
if not "%DN%"=="20" goto DataCheck
if "%DN%"=="20" goto LangContinue

:LangContinue
set "ARFiles=%D1IncludeAR% %D1ExcludeAR% %D2IncludeAR% %D2ExcludeAR% %D3IncludeAR% %D3ExcludeAR% %D4IncludeAR% %D4ExcludeAR% %D5IncludeAR% %D5ExcludeAR% %D6IncludeAR% %D6ExcludeAR% %D7IncludeAR% %D7ExcludeAR% %D8IncludeAR% %D8ExcludeAR% %D9IncludeAR% %D9ExcludeAR% %D10IncludeAR% %D10ExcludeAR% %D11IncludeAR% %D11ExcludeAR% %D12IncludeAR% %D12ExcludeAR% %D13IncludeAR% %D13ExcludeAR% %D14IncludeAR% %D14ExcludeAR% %D15IncludeAR% %D15ExcludeAR% %D16IncludeAR% %D16ExcludeAR% %D17IncludeAR% %D17ExcludeAR% %D18IncludeAR% %D18ExcludeAR% %D19IncludeAR% %D19ExcludeAR% %D20IncludeAR% %D20ExcludeAR%"
set "CZFiles=%D1IncludeCZ% %D1ExcludeCZ% %D2IncludeCZ% %D2ExcludeCZ% %D3IncludeCZ% %D3ExcludeCZ% %D4IncludeCZ% %D4ExcludeCZ% %D5IncludeCZ% %D5ExcludeCZ% %D6IncludeCZ% %D6ExcludeCZ% %D7IncludeCZ% %D7ExcludeCZ% %D8IncludeCZ% %D8ExcludeCZ% %D9IncludeCZ% %D9ExcludeCZ% %D10IncludeCZ% %D10ExcludeCZ% %D11IncludeCZ% %D11ExcludeCZ% %D12IncludeCZ% %D12ExcludeCZ% %D13IncludeCZ% %D13ExcludeCZ% %D14IncludeCZ% %D14ExcludeCZ% %D15IncludeCZ% %D15ExcludeCZ% %D16IncludeCZ% %D16ExcludeCZ% %D17IncludeCZ% %D17ExcludeCZ% %D18IncludeCZ% %D18ExcludeCZ% %D19IncludeCZ% %D19ExcludeCZ% %D20IncludeCZ% %D20ExcludeCZ%"
set "DEFiles=%D1IncludeDE% %D1ExcludeDE% %D2IncludeDE% %D2ExcludeDE% %D3IncludeDE% %D3ExcludeDE% %D4IncludeDE% %D4ExcludeDE% %D5IncludeDE% %D5ExcludeDE% %D6IncludeDE% %D6ExcludeDE% %D7IncludeDE% %D7ExcludeDE% %D8IncludeDE% %D8ExcludeDE% %D9IncludeDE% %D9ExcludeDE% %D10IncludeDE% %D10ExcludeDE% %D11IncludeDE% %D11ExcludeDE% %D12IncludeDE% %D12ExcludeDE% %D13IncludeDE% %D13ExcludeDE% %D14IncludeDE% %D14ExcludeDE% %D15IncludeDE% %D15ExcludeDE% %D16IncludeDE% %D16ExcludeDE% %D17IncludeDE% %D17ExcludeDE% %D18IncludeDE% %D18ExcludeDE% %D19IncludeDE% %D19ExcludeDE% %D20IncludeDE% %D20ExcludeDE%"
set "ENFiles=%D1IncludeEN% %D1ExcludeEN% %D2IncludeEN% %D2ExcludeEN% %D3IncludeEN% %D3ExcludeEN% %D4IncludeEN% %D4ExcludeEN% %D5IncludeEN% %D5ExcludeEN% %D6IncludeEN% %D6ExcludeEN% %D7IncludeEN% %D7ExcludeEN% %D8IncludeEN% %D8ExcludeEN% %D9IncludeEN% %D9ExcludeEN% %D10IncludeEN% %D10ExcludeEN% %D11IncludeEN% %D11ExcludeEN% %D12IncludeEN% %D12ExcludeEN% %D13IncludeEN% %D13ExcludeEN% %D14IncludeEN% %D14ExcludeEN% %D15IncludeEN% %D15ExcludeEN% %D16IncludeEN% %D16ExcludeEN% %D17IncludeEN% %D17ExcludeEN% %D18IncludeEN% %D18ExcludeEN% %D19IncludeEN% %D19ExcludeEN% %D20IncludeEN% %D20ExcludeEN%"
set "ESFiles=%D1IncludeES% %D1ExcludeES% %D2IncludeES% %D2ExcludeES% %D3IncludeES% %D3ExcludeES% %D4IncludeES% %D4ExcludeES% %D5IncludeES% %D5ExcludeES% %D6IncludeES% %D6ExcludeES% %D7IncludeES% %D7ExcludeES% %D8IncludeES% %D8ExcludeES% %D9IncludeES% %D9ExcludeES% %D10IncludeES% %D10ExcludeES% %D11IncludeES% %D11ExcludeES% %D12IncludeES% %D12ExcludeES% %D13IncludeES% %D13ExcludeES% %D14IncludeES% %D14ExcludeES% %D15IncludeES% %D15ExcludeES% %D16IncludeES% %D16ExcludeES% %D17IncludeES% %D17ExcludeES% %D18IncludeES% %D18ExcludeES% %D19IncludeES% %D19ExcludeES% %D20IncludeES% %D20ExcludeES%"
set "ESMXFiles=%D1IncludeESMX% %D1ExcludeESMX% %D2IncludeESMX% %D2ExcludeESMX% %D3IncludeESMX% %D3ExcludeESMX% %D4IncludeESMX% %D4ExcludeESMX% %D5IncludeESMX% %D5ExcludeESMX% %D6IncludeESMX% %D6ExcludeESMX% %D7IncludeESMX% %D7ExcludeESMX% %D8IncludeESMX% %D8ExcludeESMX% %D9IncludeESMX% %D9ExcludeESMX% %D10IncludeESMX% %D10ExcludeESMX% %D11IncludeESMX% %D11ExcludeESMX% %D12IncludeESMX% %D12ExcludeESMX% %D13IncludeESMX% %D13ExcludeESMX% %D14IncludeESMX% %D14ExcludeESMX% %D15IncludeESMX% %D15ExcludeESMX% %D16IncludeESMX% %D16ExcludeESMX% %D17IncludeESMX% %D17ExcludeESMX% %D18IncludeESMX% %D18ExcludeESMX% %D19IncludeESMX% %D19ExcludeESMX% %D20IncludeESMX% %D20ExcludeESMX%"
set "FRFiles=%D1IncludeFR% %D1ExcludeFR% %D2IncludeFR% %D2ExcludeFR% %D3IncludeFR% %D3ExcludeFR% %D4IncludeFR% %D4ExcludeFR% %D5IncludeFR% %D5ExcludeFR% %D6IncludeFR% %D6ExcludeFR% %D7IncludeFR% %D7ExcludeFR% %D8IncludeFR% %D8ExcludeFR% %D9IncludeFR% %D9ExcludeFR% %D10IncludeFR% %D10ExcludeFR% %D11IncludeFR% %D11ExcludeFR% %D12IncludeFR% %D12ExcludeFR% %D13IncludeFR% %D13ExcludeFR% %D14IncludeFR% %D14ExcludeFR% %D15IncludeFR% %D15ExcludeFR% %D16IncludeFR% %D16ExcludeFR% %D17IncludeFR% %D17ExcludeFR% %D18IncludeFR% %D18ExcludeFR% %D19IncludeFR% %D19ExcludeFR% %D20IncludeFR% %D20ExcludeFR%"
set "HUFiles=%D1IncludeHU% %D1ExcludeHU% %D2IncludeHU% %D2ExcludeHU% %D3IncludeHU% %D3ExcludeHU% %D4IncludeHU% %D4ExcludeHU% %D5IncludeHU% %D5ExcludeHU% %D6IncludeHU% %D6ExcludeHU% %D7IncludeHU% %D7ExcludeHU% %D8IncludeHU% %D8ExcludeHU% %D9IncludeHU% %D9ExcludeHU% %D10IncludeHU% %D10ExcludeHU% %D11IncludeHU% %D11ExcludeHU% %D12IncludeHU% %D12ExcludeHU% %D13IncludeHU% %D13ExcludeHU% %D14IncludeHU% %D14ExcludeHU% %D15IncludeHU% %D15ExcludeHU% %D16IncludeHU% %D16ExcludeHU% %D17IncludeHU% %D17ExcludeHU% %D18IncludeHU% %D18ExcludeHU% %D19IncludeHU% %D19ExcludeHU% %D20IncludeHU% %D20ExcludeHU%"
set "ITFiles=%D1IncludeIT% %D1ExcludeIT% %D2IncludeIT% %D2ExcludeIT% %D3IncludeIT% %D3ExcludeIT% %D4IncludeIT% %D4ExcludeIT% %D5IncludeIT% %D5ExcludeIT% %D6IncludeIT% %D6ExcludeIT% %D7IncludeIT% %D7ExcludeIT% %D8IncludeIT% %D8ExcludeIT% %D9IncludeIT% %D9ExcludeIT% %D10IncludeIT% %D10ExcludeIT% %D11IncludeIT% %D11ExcludeIT% %D12IncludeIT% %D12ExcludeIT% %D13IncludeIT% %D13ExcludeIT% %D14IncludeIT% %D14ExcludeIT% %D15IncludeIT% %D15ExcludeIT% %D16IncludeIT% %D16ExcludeIT% %D17IncludeIT% %D17ExcludeIT% %D18IncludeIT% %D18ExcludeIT% %D19IncludeIT% %D19ExcludeIT% %D20IncludeIT% %D20ExcludeIT%"
set "JPFiles=%D1IncludeJP% %D1ExcludeJP% %D2IncludeJP% %D2ExcludeJP% %D3IncludeJP% %D3ExcludeJP% %D4IncludeJP% %D4ExcludeJP% %D5IncludeJP% %D5ExcludeJP% %D6IncludeJP% %D6ExcludeJP% %D7IncludeJP% %D7ExcludeJP% %D8IncludeJP% %D8ExcludeJP% %D9IncludeJP% %D9ExcludeJP% %D10IncludeJP% %D10ExcludeJP% %D11IncludeJP% %D11ExcludeJP% %D12IncludeJP% %D12ExcludeJP% %D13IncludeJP% %D13ExcludeJP% %D14IncludeJP% %D14ExcludeJP% %D15IncludeJP% %D15ExcludeJP% %D16IncludeJP% %D16ExcludeJP% %D17IncludeJP% %D17ExcludeJP% %D18IncludeJP% %D18ExcludeJP% %D19IncludeJP% %D19ExcludeJP% %D20IncludeJP% %D20ExcludeJP%"
set "KRFiles=%D1IncludeKR% %D1ExcludeKR% %D2IncludeKR% %D2ExcludeKR% %D3IncludeKR% %D3ExcludeKR% %D4IncludeKR% %D4ExcludeKR% %D5IncludeKR% %D5ExcludeKR% %D6IncludeKR% %D6ExcludeKR% %D7IncludeKR% %D7ExcludeKR% %D8IncludeKR% %D8ExcludeKR% %D9IncludeKR% %D9ExcludeKR% %D10IncludeKR% %D10ExcludeKR% %D11IncludeKR% %D11ExcludeKR% %D12IncludeKR% %D12ExcludeKR% %D13IncludeKR% %D13ExcludeKR% %D14IncludeKR% %D14ExcludeKR% %D15IncludeKR% %D15ExcludeKR% %D16IncludeKR% %D16ExcludeKR% %D17IncludeKR% %D17ExcludeKR% %D18IncludeKR% %D18ExcludeKR% %D19IncludeKR% %D19ExcludeKR% %D20IncludeKR% %D20ExcludeKR%"
set "PLFiles=%D1IncludePL% %D1ExcludePL% %D2IncludePL% %D2ExcludePL% %D3IncludePL% %D3ExcludePL% %D4IncludePL% %D4ExcludePL% %D5IncludePL% %D5ExcludePL% %D6IncludePL% %D6ExcludePL% %D7IncludePL% %D7ExcludePL% %D8IncludePL% %D8ExcludePL% %D9IncludePL% %D9ExcludePL% %D10IncludePL% %D10ExcludePL% %D11IncludePL% %D11ExcludePL% %D12IncludePL% %D12ExcludePL% %D13IncludePL% %D13ExcludePL% %D14IncludePL% %D14ExcludePL% %D15IncludePL% %D15ExcludePL% %D16IncludePL% %D16ExcludePL% %D17IncludePL% %D17ExcludePL% %D18IncludePL% %D18ExcludePL% %D19IncludePL% %D19ExcludePL% %D20IncludePL% %D20ExcludePL%"
set "PRFiles=%D1IncludePR% %D1ExcludePR% %D2IncludePR% %D2ExcludePR% %D3IncludePR% %D3ExcludePR% %D4IncludePR% %D4ExcludePR% %D5IncludePR% %D5ExcludePR% %D6IncludePR% %D6ExcludePR% %D7IncludePR% %D7ExcludePR% %D8IncludePR% %D8ExcludePR% %D9IncludePR% %D9ExcludePR% %D10IncludePR% %D10ExcludePR% %D11IncludePR% %D11ExcludePR% %D12IncludePR% %D12ExcludePR% %D13IncludePR% %D13ExcludePR% %D14IncludePR% %D14ExcludePR% %D15IncludePR% %D15ExcludePR% %D16IncludePR% %D16ExcludePR% %D17IncludePR% %D17ExcludePR% %D18IncludePR% %D18ExcludePR% %D19IncludePR% %D19ExcludePR% %D20IncludePR% %D20ExcludePR%"
set "PRBRFiles=%D1IncludePRBR% %D1ExcludePRBR% %D2IncludePRBR% %D2ExcludePRBR% %D3IncludePRBR% %D3ExcludePRBR% %D4IncludePRBR% %D4ExcludePRBR% %D5IncludePRBR% %D5ExcludePRBR% %D6IncludePRBR% %D6ExcludePRBR% %D7IncludePRBR% %D7ExcludePRBR% %D8IncludePRBR% %D8ExcludePRBR% %D9IncludePRBR% %D9ExcludePRBR% %D10IncludePRBR% %D10ExcludePRBR% %D11IncludePRBR% %D11ExcludePRBR% %D12IncludePRBR% %D12ExcludePRBR% %D13IncludePRBR% %D13ExcludePRBR% %D14IncludePRBR% %D14ExcludePRBR% %D15IncludePRBR% %D15ExcludePRBR% %D16IncludePRBR% %D16ExcludePRBR% %D17IncludePRBR% %D17ExcludePRBR% %D18IncludePRBR% %D18ExcludePRBR% %D19IncludePRBR% %D19ExcludePRBR% %D20IncludePRBR% %D20ExcludePRBR%"
set "RUFiles=%D1IncludeRU% %D1ExcludeRU% %D2IncludeRU% %D2ExcludeRU% %D3IncludeRU% %D3ExcludeRU% %D4IncludeRU% %D4ExcludeRU% %D5IncludeRU% %D5ExcludeRU% %D6IncludeRU% %D6ExcludeRU% %D7IncludeRU% %D7ExcludeRU% %D8IncludeRU% %D8ExcludeRU% %D9IncludeRU% %D9ExcludeRU% %D10IncludeRU% %D10ExcludeRU% %D11IncludeRU% %D11ExcludeRU% %D12IncludeRU% %D12ExcludeRU% %D13IncludeRU% %D13ExcludeRU% %D14IncludeRU% %D14ExcludeRU% %D15IncludeRU% %D15ExcludeRU% %D16IncludeRU% %D16ExcludeRU% %D17IncludeRU% %D17ExcludeRU% %D18IncludeRU% %D18ExcludeRU% %D19IncludeRU% %D19ExcludeRU% %D20IncludeRU% %D20ExcludeRU%"
set "ZHFiles=%D1IncludeZH% %D1ExcludeZH% %D2IncludeZH% %D2ExcludeZH% %D3IncludeZH% %D3ExcludeZH% %D4IncludeZH% %D4ExcludeZH% %D5IncludeZH% %D5ExcludeZH% %D6IncludeZH% %D6ExcludeZH% %D7IncludeZH% %D7ExcludeZH% %D8IncludeZH% %D8ExcludeZH% %D9IncludeZH% %D9ExcludeZH% %D10IncludeZH% %D10ExcludeZH% %D11IncludeZH% %D11ExcludeZH% %D12IncludeZH% %D12ExcludeZH% %D13IncludeZH% %D13ExcludeZH% %D14IncludeZH% %D14ExcludeZH% %D15IncludeZH% %D15ExcludeZH% %D16IncludeZH% %D16ExcludeZH% %D17IncludeZH% %D17ExcludeZH% %D18IncludeZH% %D18ExcludeZH% %D19IncludeZH% %D19ExcludeZH% %D20IncludeZH% %D20ExcludeZH%"

My problems begins here:

if "%ARFiles%"=="" Set "ShowAR=0"
if not "%ARFiles%"=="" Set "ShowAR=1"
if "%CZFiles%"=="" Set "ShowCZ=0"
if not "%CZFiles%"=="" Set "ShowCZ=1"
if "%DEFiles%"=="" Set "ShowDE=0"
if not "%DEFiles%"=="" Set "ShowDE=1"
if "%ENFiles%"=="" Set "ShowEN=0"
if not "%ENFiles%"=="" Set "ShowEN=1"
if "%ESFiles%"=="" Set "ShowES=0"
if not "%ESFiles%"=="" Set "ShowES=1"
if "%ESMXFiles%"=="" Set "ShowESMX=0"
if not "%ESMXFiles%"=="" Set "ShowESMX=1"
if "%FRFiles%"=="" Set "ShowFR=0"
if not "%FRFiles%"=="" Set "ShowFR=1"
if "%HUFiles%"=="" Set "ShowHU=0"
if not "%HUFiles%"=="" Set "ShowHU=1"
if "%ITFiles%"=="" Set "ShowIT=0"
if not "%ITFiles%"=="" Set "ShowIT=1"
if "%JPFiles%"=="" Set "ShowJP=0"
if not "%JPFiles%"=="" Set "ShowJP=1"
if "%KRFiles%"=="" Set "ShowKR=0"
if not "%KRFiles%"=="" Set "ShowKR=1"
if "%PLFiles%"=="" Set "ShowPL=0"
if not "%PLFiles%"=="" Set "ShowPL=1"
if "%PRFiles%"=="" Set "ShowPR=0"
if not "%PRFiles%"=="" Set "ShowPR=1"
if "%PRBRFiles%"=="" Set "ShowPRBR=0"
if not "%PRBRFiles%"=="" Set "ShowPRBR=1"
if "%RUFiles%"=="" Set "ShowRU=0"
if not "%RUFiles%"=="" Set "ShowRU=1"
if "%ZHFiles%"=="" Set "ShowZH=0"
if not "%ZHFiles%"=="" Set "ShowZH=1"

set /a "OptNum=%ShowAR%+%ShowCZ%+%ShowDE%+%ShowEN%+%ShowES%+%ShowESMX%+%ShowFR%+%ShowHU%+%ShowIT%+%ShowJP%+%ShowKR%+%ShowPL%+%ShowPR%+%ShowPRBR%+%ShowRU%+%ShowZH%"


set #=0

if "%ShowAR%"=="1" set /a #=%#%+1
if "%ShowAR%"=="1" echo [%#%] Arabic
if "%ShowCZ%"=="1" set /a #=%#%+1
if "%ShowCZ%"=="1" echo [%#%] Czech
if "%ShowDE%"=="1" set /a #=%#%+1
if "%ShowDE%"=="1" echo [%#%] German
if "%ShowEN%"=="1" set /a #=%#%+1
if "%ShowEN%"=="1" echo [%#%] English
if "%ShowES%"=="1" set /a #=%#%+1
if "%ShowES%"=="1" echo [%#%] Spanish
if "%ShowESMX%"=="1" set /a #=%#%+1
if "%ShowESMX%"=="1" echo [%#%] Mexican
if "%ShowFR%"=="1" set /a #=%#%+1
if "%ShowFR%"=="1" echo [%#%] French
if "%ShowHU%"=="1" set /a #=%#%+1
if "%ShowHU%"=="1" echo [%#%] Hungarian
if "%ShowIT%"=="1" set /a #=%#%+1
if "%ShowIT%"=="1" echo [%#%] Italian
if "%ShowJP%"=="1" set /a #=%#%+1
if "%ShowJP%"=="1" echo [%#%] Japanese
if "%ShowKR%"=="1" set /a #=%#%+1
if "%ShowKR%"=="1" echo [%#%] Korean
if "%ShowPL%"=="1" set /a #=%#%+1
if "%ShowPL%"=="1" echo [%#%] Polish
if "%ShowPR%"=="1" set /a #=%#%+1
if "%ShowPR%"=="1" echo [%#%] Portuguese
if "%ShowPRBR%"=="1" set /a #=%#%+1
if "%ShowPRBR%"=="1" echo [%#%] Portuguese (Brazil)
if "%ShowRU%"=="1" set /a #=%#%+1
if "%ShowRU%"=="1" echo [%#%] Russian
if "%ShowZH%"=="1" set /a #=%#%+1
if "%ShowZH%"=="1" echo [%#%] Chinese

From some reason, even when the ARFiles. CZFiles, etc, are empty, the ShowAR, ShowCZ, etc, values are still being set to 1, instead of 0 like I need it to be.

The OptNum variable is still unused but it should be set by adding the result of the Show variables together.

For example: If the ini files only have values entered for languages English. German & French, the ShowEN, ShowDE & ShowFR need to be set to 1, all the rest of the Show values need to be set to 0, then OptNum variable should add all these together, which should result in OptNum=3.

Right now, all Show variables are set to 1, no matter what, which results in OptNum=16.

I can't find the problem, I've done similar empty variable checks before and it worked, Can you help me?

Here's an example of one of the ini file I check, I only check for the IncludeAR, IncludeCZ, etc. & the ExcludeAR, ExcludeCZ, etc. variables.

#===============================================================================================#
#================================  DATA FILE VARIABLES SETUP  ==================================#
#===============================================================================================#


#===============================================================================================#
#==================================  COMPRESSION VARIABLES  ====================================#
#===============================================================================================#
# Set here the type of compression software to use (arc, 7zip, rar) and the compression method  #
# to use, refer to the UCC tutorial for a partial list of available methods, type the method    #
# without the -m/-mx prefix.                                                                    #
#===============================================================================================#

Compressor=rar
Method=0


#===============================================================================================#
#======================================  DISC VARIABLE  ========================================#
#===============================================================================================#
#======== Set here the number of the disc/temp folder this data file will be created in ========#
#===============================================================================================#

Disc=1

#===============================================================================================#
#========================================== INCLUDE ============================================#
#===============================================================================================#
#============= Set here the name of the list of files to include in this data file =============#
#===============================================================================================#
#================= Use quote marks (") around files/folders with spaces in them ================#
#===============================================================================================#

Include=_CommonRedist\* bink2w32.dll steam_api.dll steam_api.cdx steam_api.ini LRFF13.exe DirectInput.ini weiss_data\dlc\* weiss_data\sys\* weiss_data\movie\moviea*.bin
IncludeAR=test
IncludeCZ=
IncludeDE=test test
IncludeEN=test test
IncludeES=
IncludeESMX=test
IncludeFR=
IncludeHU=
IncludeIT=test test
IncludeJP=
IncludeKR=
IncludePL=
IncludePR=
IncludePRBR=
IncludeRU=
IncludeZH=

#===============================================================================================#
#========================================== EXCLUDE ============================================#
#===============================================================================================#
#============ Set here the name of the list of files to exclude from this data file ============#
#===============================================================================================#
#================= Use quote marks (") around files/folders with spaces in them ================#
#===============================================================================================#
#=============== If more than 1 file entered use quote marks (") around each file ==============#
#===============================================================================================#

Exclude="Unins*" "weiss_data\sys\white_img*"
ExcludeAR=
ExcludeCZ=
ExcludeDE=
ExcludeEN=tested
ExcludeES=
ExcludeESMX=
ExcludeFR=
ExcludeHU=
ExcludeIT="test" "testing"
ExcludeJP=
ExcludeKR=
ExcludePL=
ExcludePR=
ExcludePRBR=
ExcludeRU=
ExcludeZH=



#===============================================================================================#
#=======================================  END OF FILE  =========================================#
#===============================================================================================#
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
VollachR
  • 35
  • 8
  • Your logic is wrong, you ask if the variable is enpty and set it to `0` in case; then you ask if it is not empty (you just set it to `0`), so it becomes `1`; you need to use `else` instead of `if not` -- see `if /?` for the correct syntax... – aschipfl Jan 08 '16 at 18:12
  • `if defined ARFiles (Set "ShowAR=1") else Set "ShowAR=0"` – Aacini Jan 08 '16 at 18:42

1 Answers1

0

I apologize in advance for this reply. The questions posted here should be as concise as possible, so the people can concentrate the attention on the problem. If you post a lot of code unrelated to the problem, then you may get similar answers...

Your method is wrong. This ridiculously long line:

set "ARFiles=%D1IncludeAR% %D1ExcludeAR% %D2IncludeAR% %D2ExcludeAR% %D3IncludeAR% %D3ExcludeAR% %D4IncludeAR% %D4ExcludeAR% %D5IncludeAR% %D5ExcludeAR% %D6IncludeAR% %D6ExcludeAR% %D7IncludeAR% %D7ExcludeAR% %D8IncludeAR% %D8ExcludeAR% %D9IncludeAR% %D9ExcludeAR% %D10IncludeAR% %D10ExcludeAR% %D11IncludeAR% %D11ExcludeAR% %D12IncludeAR% %D12ExcludeAR% %D13IncludeAR% %D13ExcludeAR% %D14IncludeAR% %D14ExcludeAR% %D15IncludeAR% %D15ExcludeAR% %D16IncludeAR% %D16ExcludeAR% %D17IncludeAR% %D17ExcludeAR% %D18IncludeAR% %D18ExcludeAR% %D19IncludeAR% %D19ExcludeAR% %D20IncludeAR% %D20ExcludeAR%"

... assign 39 spaces to ARFiles variable when all DiIncludeAR and DiExcludeAR elements are not defined; this means that this IF command:

if "%ARFiles%"=="" Set "ShowAR=0"

is never true. You may solve this problem removing the spaces between all elements. However, the method you use to process the array elements is pretty inefficient. The advantages of an array is that you may process all its elements writting just one element with a subscript and change it in a FOR command. If you analyze your code, you will realize that most of your operations can be achieved with variables with any other names, because you repeat their whole names in all operations.

Below is a new code that obtain an equivalent result than your code, but that fully exploits the capabilities of array management in Batch files.

EDIT: I slightly modified the code in order to correctly process the example data (after it was posted by the OP).

@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"
   )
)


REM Show the language menu
set #=0
for %%a in (%langs%) do (
   if defined Show%%a (
      set /a #+=1
      echo [!#!] !lang[%%a]!
   )
)

ECHO/
ECHO OptNum = %OptNum%

The output displayed by previous code with the example data is:

[1] Arabic
[2] German
[3] English
[4] Spanish (Mexico)
[5] Italian

OptNum = 5

A final question: if "PRBR" is "Portuguese (Brazil)", why "ESMX" is not "Spanish (Mexico)"? There is not such "Mexican" language (unless you are referring to Nahuatl).

Community
  • 1
  • 1
Aacini
  • 65,180
  • 12
  • 72
  • 108
  • OK... First thing, the ESMX being "Mexican" is just temporary laziness on my part, it won't be in the final file. 2nd, your script doesn't work for me unless I rem the Setlocal line, and even then it imports all variables from the ini file, which is wrong, I only need the Include/Exclude language variables, and 3rd, it doesn't set the show variables at all, I still keep getting a full 16 language menu. when I type set to see the set variables there's this in there: `Show!lang:~7~=1` instead of the ShowAR, ShowCZ, etc. – VollachR Jan 09 '16 at 10:48
  • See the edit in my answer. Please, do NOT modify the code in any way when you test it! For example, my original code had `set Show!lang:~7!=1`, but your previous comment show that you changed the second `!` by a `~`! – Aacini Jan 09 '16 at 15:33
  • I only modified your code when things didn't work to try and adjust it. but OK, The new modification on your suggested script seems to work, now on to the next problem I guess... I need to set user input, that's easy enough `set /p choice=make selection:` should do it, my next problem is how to export the selected language to a value, preferably by using the language short code but even full lang name is good, hopefully I can figure it out on my own, but suggestions are very welcome. – VollachR Jan 09 '16 at 15:41
  • I suggest you to select my answer (click on the check-mark) and upvote it when you have enough rep to do so; this is the way you say "thanks" for the aid provided... After that, you may post a new question where you clearly describe this new request in a way _as clear and concise as possible_! You may include a link to this question as reference. In your questions you always must give an example of _the input_ and _the desired output_ with such input. – Aacini Jan 09 '16 at 15:51
  • I know it's been a while but I got a question regarding that menu script you gave me, currently it only looks for Data#.ini files 1-20, what if I wanted to check for unlimited number of Data#.ini files, not just 20? how do I change the script for that? do I just remove the 20 from the `in (1,1,20) do` part of the code? I'm not good with `FOR` commands. – VollachR Jan 23 '16 at 12:12