>Hi. Is there a function (in Fox) that will sum the digits in a number? I need to create a hash total for my electronic bank data.
>
>Thanks, Randy
No native function. You can write your own, though, like this (probably not the best algorithm):
lnNumbers=12345678901000
lcStr = alltrim(padr(m.lnNumbers,100))
lnSum = 0
for lnI=1 to len(m.lcStr)
lnSum=m.lnSum+val(substr(m.lcStr,m.lnI,1))
next
If it's not broken, fix it until it is.
My Blog