Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Can we display the content of a variable that itself is the content of another ?  (Read 46501 times)

0 Members and 1 Guest are viewing this topic.

Abo-Zead

    Topic Starter


    Beginner
  • Thanked: 1
  • Experience: Familiar
  • OS: Windows 10
Hi all

How to display the content of a variable that is itself composed of a variable
for example, if we have a variable its name is Age and contain on value 35 , so we can display its value by writing the below line in batch scripting.

Code: [Select]
set "Age=35"
echo %Age%
and the result will be '35'

but if the name itself of that variable is inside another variable like the below line

Code: [Select]
set "var=Age"
set "%Age%=35"

, so we can display the content of 'var' variable by the below line

Code: [Select]
echo %var% and the result will be 'Age'
my question here is :
Can we display the content of 'Age' variable using 'var' variable?
And if we can How to do this step?

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Code: [Select]
@echo off
set "var=Age"
set "%var%=35"
call echo %%%var%%%
SETLOCAL ENABLEDELAYEDEXPANSION
echo !%var%!

Abo-Zead

    Topic Starter


    Beginner
  • Thanked: 1
  • Experience: Familiar
  • OS: Windows 10
Thanks and Appreciate Squashman