|
gmueller Apprentice
Joined: 06 Apr 2004 Posts: 173
|
Posted: 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 {+} |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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 |
|
|
|
|
|