Batch - Echo value of variables in another variable?

Viewed 661

On the Batch-file I am currently working on, I've encountered a small problem. I have a file called Dimensions(number from 1-5, defined in a for /l loop).txt in which contains %b1%%b2%%b3%%b4%%b5%. I want to be able to echo the values of %b1%%b2%%b3%%b4%%b5% through a value, for example being string1 which was set via set /p string1=<Dimensions1.txt.

In other words, I want to be able to use echo %string1% (which consist of 5 variables), and have those variable's values echo'd. If this doesn't make sense, here's my code sample;

for /l %%g in (1,1,%height%) do (
set /p line%%g=<Dimensions%%g.txt
)
:Nextstep
echo Use WASD to move over the map, and select tiles.
for /l %%h in (1,1,%height%) do (
pause
echo %line1%
echo %%line%%h%%
)

While Dimensions1.txt (The first which should be set into %line1%) looks like this;

%b1%%b2%%b3%%b4%%b5%

In echo %%line%%h%%, the %%'s should cancel eachother out, excluding %%h which should be 1. Desired to be; %line1% (which is, as I said, %b1%%b2% etc....), however printing their values.

Right now all I get is %line1%. I've tried other methods such as, as someone commented on my last (somewhat similar) question, to do set percent=%% (with setlocal EnableDelayedExpansions) and use !percent! on the outsides, however that, neither, gave me the desired output.

1 Answers
Related