Excuse me. Although your problem is directly related to Delayed Expansion as npocmaka indicated in his answer, I would like to attract your attention to the following advice.
When you use Delayed Expansion you may make good use of the fact that the second (delayed) !expansion! may work over text that has been previously modified or %expanded%. This is a powerful Batch file feature that may avoid complex manipulations.
For example, suppose that you have a variable called result
that will store the sum of another variable called term
plus the values 1, 2, 3 and 11. One way to do that is this:
for %%a in (1 2 3 11) do (
if %%a == 1 (
set /A result=term+1
) else if %%a == 2 (
set /A result=term+2
) else if %%a == 3 (
set /A result=term+3
) else if %%a == 11 (
set /A result=term+11
)
echo The sum of !term! plus %%a is !result!
)
However, you may conclude that all those IF's are not necessary, because you may directly take the value of the second term this way:
for %%a in (1 2 3 11) do (
set /A result=term+%%a
echo The sum of !term! plus %%a is !result!
)
Well, the same conclusion may be used in your code this way:
@echo off
setlocal EnableDelayedExpansion
rem Create CONFIGS_QUASAR 1, 2, 3 and 0B strings
FOR %%A IN (1 2 3 0B) DO (
rem Initialize this string
SET "CONFIGS_QUASAR%%A="
rem Fill this string with their values
FOR /L %%I IN (1,1,6) DO SET "CONFIGS_QUASAR%%A=!CONFIGS_QUASAR%%A! Q%%A_%%I"
)
FOR %%A IN (1 2 3 0B) DO (
SET CONFIGS=!CONFIGS_QUASAR%%A!
echo QUASAR%%A
echo !CONFIGS!
)
pause
Output:
QUASAR1
Q1_1 Q1_2 Q1_3 Q1_4 Q1_5 Q1_6
QUASAR2
Q2_1 Q2_2 Q2_3 Q2_4 Q2_5 Q2_6
QUASAR3
Q3_1 Q3_2 Q3_3 Q3_4 Q3_5 Q3_6
QUASAR0B
Q0B_1 Q0B_2 Q0B_3 Q0B_4 Q0B_5 Q0B_6
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…