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
Tanuki
Novice


Joined: 06 Nov 2008
Posts: 38

PostPosted: Tue Jan 18, 2011 12:44 am   

Need Help with ForAll loop in Function
 
I'm trying to use a Forall loop inside of a Function but the %1 which should reference the current value in the Forall loop seems to reference the parameter instead.

Here is an example Function. If someone could clarify what I am doing wrong I would appreciate it.



This should return 10
but instead returns 01|2|3|41|2|3|41|2|3|41|2|3|4

<func name="TestFunction" type="StringList" id="534">
<value>;#var list {1|2|3|4}
;#show @TestFunction(@list)

ReturnValue = 0
#forall ($para1) {

#MATH ReturnValue @ReturnValue+%1

}

#return @returnValue</value>
<arglist>$para1</arglist>
</func>
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jan 18, 2011 1:23 am   
 
%i, not %1 :). And in a nested loop it continues in order to the next letter: %j
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Tanuki
Novice


Joined: 06 Nov 2008
Posts: 38

PostPosted: Tue Jan 18, 2011 1:37 am   
 
Thank you!
Reply with quote
Tanuki
Novice


Joined: 06 Nov 2008
Posts: 38

PostPosted: Tue Jan 18, 2011 1:37 am   
 
Thank you!
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