Average function

Tom Vawter tvawter at austincc.edu
Sun Jan 28 14:21:33 EST 2007


>Recently, Tom Vawter wrote:
>
>> Is there an average function that will not consider blank fields?  For
>> instance, if I have 10 and 8 in two fields and an empty third field, I
>> want to take the average of the numbers in the three fields and get 9
>> rather than 6.
>
>Could you do this?
>
> function nonemtpyAverage
>    put 0 into N
>    put 0 into tTotal
>    repeat with F = 1 to number of flds
>       add fld F to tTotal
>       if fld F <> "" then add 1 to N
>    end repeat
>    return tTotal/N
> end nonemtpyAverage
>
>You may need to limit the number of fields you want to check.
>
>Regards,
>
>Scott Rossi
>Creative Director
>Tactile Media, Multimedia & Design
>-----
>E: scott at tactilemedia.com
>W: http://www.tactilemedia.com
>
>
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-revolution
Thanks, Scott.  It works fine.  The only problem I had was with other
label fields crashing the party.   I temporarily remedied this by
putting a 3 in for "number of flds" - mine are fortunately numbered 1 to
3.  What I need to know is how to code to restrict the fields considered.

Thanks again
Tom Vawter




More information about the use-livecode mailing list