Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

Is it possible for a variable inside of a variable?

I'm pretty rusty with batch and am looking for a way to do this or a way around it.
The script is
Code
set var%setnum%= %str:~!str1!,!str2!%
Where %setnum% is equal to 1, %str% is equal to the alphabet (ABCD...), %str1% is equal to 0, and %str2% is equal to 1.
so that it would display like
Code
Set var1= ABCDEFGHIJKLMNOPQRSTUVWXYZ:~0,1
That way if I were to echo %var1% is would display "A"
You want the variable's name to correspond with a letter of the alphabet?
Code
setlocal enabledelayedexpansion
set str=ABCDEFGHIJKLMNOPQRSTUVWXYZ
for /l %%A in (0,1,25) do (
set /a num=%%A+1
set var!num!=!str:~%%A,1!
)
(Dec 9, 2014 03:01 PM)Topkek_Is_Life Wrote:  I'm pretty rusty with batch and am looking for a way to do this or a way around it.
The script is
Code
set var%setnum%= %str:~!str1!,!str2!%
Where %setnum% is equal to 1, %str% is equal to the alphabet (ABCD...), %str1% is equal to 0, and %str2% is equal to 1.
so that it would display like
Code
Set var1= ABCDEFGHIJKLMNOPQRSTUVWXYZ:~0,1
That way if I were to echo %var1% is would display "A"

When you're storing a variable, you're storing the actual value of the variable and not how to get the variable. It will expand that entire line, and then perform what it says.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by DoxinYourBotnetM8Mar 19, 2015 06:23 PM 21 394 Mar 19, 2015 06:23 PM
Last Post: Nakamoto.
[Java] by TizenDec 13, 2014 07:58 PM 10 319 Dec 13, 2014 07:58 PM
Last Post: Tizen
[Shell] by 'PalladiumOct 6, 2014 10:39 PM 5 115 Oct 6, 2014 10:39 PM
Last Post: 'Palladium