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
zmudnoob
Beginner


Joined: 09 Sep 2005
Posts: 14

PostPosted: Tue Sep 13, 2005 8:50 pm   

easy scripting help
 
I'm using zmud 7.13b in windows xp and trying to create an alias that will take each item from one variable (@stringlist) and put it into another variable (@new) but with each item numbered and on it's own line. I can easily put each on it's own line with %expandlist(@stringlist,%cr) so the old variable (@stringlist) contains:

a bag of tricks|small ice cream cone|purple earring

and the new variable (@new) looks like:

a bag of tricks
small ice cream cone
purple earring

what I want is the new variable (@new) to actually look like:

1:a bag of tricks
2:small ice cream cone
3:purple earring

It seems like this should be easy to do but I just can't get my head around it because I'm fairly new to scripting. Any help would be greatly appreciated.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Sep 13, 2005 9:05 pm   
 
#alias enumerate {#loop 1,%numitems(@%1) {#variable %2 %replaceitem(%concat(%i,":",%item(%1,%i)),%i,%1)}}

%1 -- old list
%2 -- new list

enumerate old new
_________________
EDIT: I didn't like my old signature
Reply with quote
zmudnoob
Beginner


Joined: 09 Sep 2005
Posts: 14

PostPosted: Tue Sep 13, 2005 9:58 pm   
 
Thanks for the quick response! The alias created a new variable with the value of

3:

(because I had 3 items in the old variable) and none of the items themselves made it over to the new variable from the old. Any ideas why?
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Wed Sep 14, 2005 12:53 am   
 
This works for me if ya dont mind having another variable

#alias enumerate {
#LOOP %numitems( @new) {#ADDITEM new2 {%i: %item( @new, %i)}}
#VARIABLE new @new2
#VARIABLE new2 {} {}
}
_________________
http://www.Aardwolf.com
Reply with quote
alluran
Adept


Joined: 14 Sep 2005
Posts: 223
Location: Sydney, Australia

PostPosted: Wed Sep 14, 2005 11:07 am   
 
#alias enumerate {
#LOOP %numitems( @new) {#var new %replaceitem("1: "%item(@new,%i)%char(10)%char(13),%i,@new)}
}

that should do it with no new variables needed
_________________
The Drake Forestseer
Reply with quote
zmudnoob
Beginner


Joined: 09 Sep 2005
Posts: 14

PostPosted: Wed Sep 14, 2005 1:05 pm   
 
Yay! Got it working very nicely :-) Thank you all for your help.
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