|
shazara Beginner
Joined: 17 Feb 2003 Posts: 16 Location: USA
|
Posted: 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. |
|
|
|
zwanth Beginner
Joined: 13 Jul 2002 Posts: 16 Location: USA
|
Posted: 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. |
|
|
|
shazara Beginner
Joined: 17 Feb 2003 Posts: 16 Location: USA
|
Posted: Sun Sep 14, 2003 4:37 am |
That works fine. Thank you!
|
|
|
|
|
|