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
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Tue Jan 25, 2005 7:13 pm   

function help
 
ok im not sure why this doesnt work

#FUNCTION calculate_score {%numitems(%1);#LOOP %numitems(%1) {+%item(%1,%i)}}


im expecting #SHOW @calculate_score("0|1") to display:
2+0+1

but instead it does:
2;#LOOP 2 {+}
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Jan 26, 2005 12:14 am   Re: function help
 
gmueller wrote:
ok im not sure why this doesnt work

#FUNCTION calculate_score {%numitems(%1);#LOOP %numitems(%1) {+%item(%1,%i)}}


im expecting #SHOW @calculate_score("0|1") to display:
2+0+1

but instead it does:
2;#LOOP 2 {+}


Functions cannot directly execute #commands of any type. To make these work, you need to surround the entire thing with %exec(). I made a big jump from 6.62 to 7.05a, so things may have changed but that's the last thing I remember learning about Functions.
_________________
EDIT: I didn't like my old signature
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jan 26, 2005 10:57 am   
 
It is always better to eliminate a #LOOP whenever possible.
#FUNCTION calculate_score {%eval(%replace(%1,"|","+"))}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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