Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Eiredrake
Beginner


Joined: 14 Jun 2005
Posts: 15

PostPosted: 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
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Fri Jun 12, 2009 7:14 am   
 
Try;
$STAT_NAME = "Access"
#var %eval($STAT_NAME) "NewValue"

There's some examples in the manual, #VARIABLE.
Reply with quote
yilean
Beginner


Joined: 30 Sep 2002
Posts: 15
Location: Spain

PostPosted: 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.
Reply with quote
Eiredrake
Beginner


Joined: 14 Jun 2005
Posts: 15

PostPosted: 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.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net