How to expand variable in another variable with string substitution?
Posted: 11 Jan 2020 15:19
Sorry about the confusing title, but I couldn't think about any other way to word it. Basically, I have some variables, for example:
And another one, which contains the "var" prefix, but not that specific number, like:
I'm trying to use it like:
To hopefully get the value of %var[1]%, but obviously it's already been expanded when it was SET above, so it gives nothing. I've tried doubling the %% and using CALL SET, but so far to no avail. Using DELAYEDEXPANSION isn't an option either, since I'm substituting variables with delayed expansion already.
Any tips or guidance would be much appreciated.
Thanks in advance, Lowsun
Code: Select all
SET var[1]=12
SET var[2]=23
Code: Select all
SET displayvar=%var[#]%
Code: Select all
SET /A var=%displayvar:#=1%
Any tips or guidance would be much appreciated.
Thanks in advance, Lowsun