-
Very Weird Question. Is This Possible???
Ok.... lets say I have a variable called "blah". it reads in from a datebase the word "numOfPlayers". So now we have :
blah = "numOfPlayers"
now the tricky part is that i have an actualy variable that is called "numOfPlayers". And want I want to do is find out what the value of it is (and yes... i know I can just go newVar = numOfplayers.... but I need to use whatever variable blah receieves fromt he database)
So essentially I have a variable within another variable. I can't thnk of how to do this.
I've tried things like :
newVar = blah.valueOf();
newVar = blah.valuOf().valueOf();
etc...
not sure how this is possible....
Any ideas? And help or suggestions at all would be greatly appreciated!!!
Ryan
-
Not sure how you are trying to pass the variable.
to pass the value, you would just tell it that
numOfPlayers = blah.
Since you seem to not want that, could you tell maybe why the value needs to be renamed? A little context?
-
Hey, first of all, thanx for your reply..
Ok... I apologize for explaining it poorly.
Basicalling I already have about 100 existing variables in my mc.... lets call them var1, var2, var2....var100.
Now I have a differrent variable in my mc called blah. I use a loadVariables command to get infomation from a database...
so lets say afetr loading info from the database we now have :
blah = "var13"
now blah doesn't equal the contents of the already existing var13... it just equals the string "var13".
So what i need is blah to go to the real varibale var13 that previously existed... and get it's value. So assuming var13 had "2004" as it's contents.
After the database loaded the string of "var13" from the database and put it into the varible "blah"... blah would go out and find what was stored in the real varibale "var13".
therefore the final result blah = 2004 (and not the string "var13")
Geez... i probably made that worse...
anyone have any idea??
I've been stuck on this for 3 hours now and can't find any solutions on the web.
Thanx
Ryan
-
Let's see if I have this straight...
From the DB, you'll grab "numOfPlayers" or whatever variable.
THEN, you need to find the value of the existing variable [numOfPlayers] that you just got from the database?
have you tried using "eval()"?
//code:
blah = "numOfPlayers";
newBlah = eval(blah);
//end of code
that will set newBlah to whatever the real value of "numOfPlayers" is.
-
You're my hero!!!
That's exactly what i was looking for! Thanx for taking the time to help me!
-Ryan
-
No problem!! That's what the boards are for.
(I'm banking my karma for when I have a question myself )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|