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
jmlester
Newbie


Joined: 30 Jun 2007
Posts: 4

PostPosted: Fri Jul 06, 2007 3:03 pm   

Variable name manipulation
 
Is it possible to dynamically generate the name of a variable?

For example, I have a string list called "MendingHeadCureList." I actually have lots of variables with "_ _ CureList." I want to be able to use the name of the variable in an alias, but have it generated based on input.

I have an alias "resetSalve." I want to be able to pass it the first and second word of the variable i'm trying to reset. For example:

resetSalve mending head

In the alias, I want it to access the MendingHeadCureList variable. So far I have tried:

@%1%2CureList
@%concat(%1,%2,CureList)

These all give me the literal string "@MendingHeadCureList" but I want to be able to access that variable.

Any hints?
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Jul 06, 2007 3:50 pm   
 
@{%concat(%1,%2,CureList)}

SHOULD be what you are looking for. I'm a zombie today so if it does not work just post again.

If you mean that you want to set the value to something.

#var (%concat(%1,%2,CureList)) {whatever}
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
jmlester
Newbie


Joined: 30 Jun 2007
Posts: 4

PostPosted: Fri Jul 06, 2007 3:57 pm   
 
That worked... thanks!
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Fri Jul 06, 2007 6:17 pm   
 
Don't forget you can always use #EXEC, too...

$varname = %concat(%1,%2,"CureList")
#EXEC %concat("#VAR ",$varname," {",$value,"}")
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
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