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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
slash_2_2000
Beginner


Joined: 27 Jul 2005
Posts: 20

PostPosted: Fri Nov 09, 2007 6:34 am   

How can I use 'concat'-ed variables in loops?
 
Yes, the subject is strange. It's a difficult problem to put into a single sentence.

Basically, I have a list of variables that start with 'cures', for instance, @cures_bob or @cures_frank. Now, I have a single alias which I want to refer to any of these variables, given the correct parameters. Basically, %1 will equal 'bob' or 'frank' and I want it to refer to the respective 'cures' variable in #FORALL and/or #LOOPDB commands. So, I want to enter 'bob' into this alias and have it come out with #LOOPDB @cures_bob {Etc} and actually work.

So, I figure, I'll use the %concat function! Nope. Doesn't work. If I concat '@cures_' with 'frank' I just get... '@cures_frank' as text, not actually referencing the variable itself. I have found one single way to make this work and it goes like so:

Code:
%exec( @%concat( cures_, %1))


For some reason, this seems to make zMUD reference the variable rather than the text. However, for some unknown reason, this method has... apparently... stopped working. The thing is, it was working fine up until about three days ago and has now stopped working. I have not changed a single thing in zMUD or my PC. However, that oddity aside...

I would really like to know if there is a better way to make this work. Any and all help would be vastly appreciated.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Nov 09, 2007 8:30 am   
 
Without knowing exactly what you are doing I can't suggest a better way of doing it. I can tell you that braces are what you are looking for. Also you really don't want the %exec function, you should use the command.
#LOOPDB @{cures_%1} {#EXEC %val}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
slash_2_2000
Beginner


Joined: 27 Jul 2005
Posts: 20

PostPosted: Fri Nov 09, 2007 10:08 am   
 
This worked brilliantly Very Happy

Thank you!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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