1

I have been having a real issue getting something that seems simple, but I can not seem to get a working answer.

Here is what I am doing:

  1. Setting a variable with a specific name: ex. set "select=computer1"
  2. I do a test and give that variable a value based on the result after using an if statement : ex set "%select%=1" This sets the variable %computer1% to 1
  3. I want to see what the value of %computer1% is however all I know is %select%.

Is there any way I can get the value of %computer1% when only knowing %select%? %select% knows the name of the new variable but I need to know its value without being able to directly call it by hard coded name.

I thought a pipeline might work but I can not seem to figure this out.

Thanks all, I appreciate your help.

Compo
  • 36,585
  • 5
  • 27
  • 39
  • `set %select%` will output `computer1=1` –  May 24 '17 at 14:12
  • 1
    This type of management is described at [this answer](https://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script/10167990#10167990), although the topic is different... – Aacini May 24 '17 at 14:22

1 Answers1

4

You need another layer of parsing. You can do it:

with delayed expansion:

setlocal enabledelayedexpansion
echo !%select%!

without delayed expansion:

call echo %%select%%
Stephan
  • 53,940
  • 10
  • 58
  • 91