|
Eiredrake Beginner
Joined: 14 Jun 2005 Posts: 15
|
Posted: Fri Jun 12, 2009 3:26 am
Set a variable inside a variable |
Greetings, I'm having trouble finding answers as to how to do something specific.
I have a parameter with the name of a variable in it. I want to set the value of the inner variable to X.
Example:
$STAT_NAME = "Access";
I want to set the Access variable to 10;
I've tried a bunch of things including using #VAR and expanding the variable. Thus far nothing has worked a few things have caused the alias this sits in to not function all. can anyone point me in a direction?
Thanks
E |
|
|
|
Rorso Wizard
Joined: 14 Oct 2000 Posts: 1368
|
Posted: Fri Jun 12, 2009 7:14 am |
Try;
$STAT_NAME = "Access"
#var %eval($STAT_NAME) "NewValue"
There's some examples in the manual, #VARIABLE. |
|
|
|
yilean Beginner
Joined: 30 Sep 2002 Posts: 15 Location: Spain
|
Posted: Fri Jun 12, 2009 8:14 am |
The solution is in an example on #VARIABLE manual:
$STAT_NAME="Access"
#VAR %eval($STAT_NAME) 10
#show @Access
#show %eval(@$STAT_NAME)
The trick is ussing #VAR command to change the global variable value.
Last line access to the global variable value: Perhaps there are simpler and better way to do that, but I don't know.
Byesss. |
|
|
|
Eiredrake Beginner
Joined: 14 Jun 2005 Posts: 15
|
Posted: Sat Jun 13, 2009 11:36 pm Thanks |
I actually tried that before and it didn't work. I'm not sure what I did wrong. But it's working now. i appreciate the assist.
|
|
|
|
|
|