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


Joined: 17 Feb 2003
Posts: 16
Location: USA

PostPosted: Sat Sep 13, 2003 1:10 pm   

Looping execution of stringlist items
 
Part of my script goes through a stringlist to split gold between a hunting group, and it does this via:

#WHILE (%numitems( @group) > 0) {give @result gold to %item( @group, 1);group=%delitem( %item( @group, 1), @group)}

The question I have, is how do I do this without deleting each item? I want to keep the names in the stringlist so I could use it later. The group varies, so it's not going to be a set amount of items in the group.

Help appreciated.
Reply with quote
zwanth
Beginner


Joined: 13 Jul 2002
Posts: 16
Location: USA

PostPosted: Sat Sep 13, 2003 5:31 pm   
 
The easy way is to use the #FORALL comand, which executes a command for each item in a list:

#IF (%numitems(@group) > 0) {#FORALL @group {give @result gold to %i}}

with the %i variable automatically being filled in with the current item in each iteration of the loop. Look at the help file for #FORALL for more information.
Reply with quote
shazara
Beginner


Joined: 17 Feb 2003
Posts: 16
Location: USA

PostPosted: Sun Sep 14, 2003 4:37 am   
 
That works fine. 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