ID:157340
 
Is it possible to create a variable from a variable. Its hard to explain in text and Dm explains better.
var/A = 50
var/B[A] = 34234
//So that the variable is called B50
The way most programming languages work, is that variables must be contstant in order for you to use them in other variables. For obvious reasons.

Since explaining it using DM is easier for you, here's an example:

var
const/dm = 10
b = dm


Now naming a variable b[dm] is completely different, because you're referencing an array (or list) of 10 cells. If you want to name a variable b10, just name it b10.
A var name has to be constant, but you can use an associative list.

var/list/mylist = new
mylist["B50"] = 34234
In response to Kirone
"If you want to name a variable b10, just name it b10."
This would work, however in what I'm coding variables need to be defined dynamically. Lummox's way will work.