Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: UDF numbers
#definefunction CurrencyAdd(x,y) xp=StrIndex(x,".",0,@fwdscan) if xp==0 ; no decimal point x1=strsub(x,11,-1) x2=".0" else x1=strsub(x,11,xp-11) x2=strsub(x,xp,-1) endif yp=StrIndex(y,".",0,@fwdscan) if yp==0 ; no decimal point y1=strsub(y,11,-1) y2=".0" else y1=strsub(y,11,yp-11) y2=strsub(y,yp,-1) endif fractmax=max(StrLen(x2),StrLen(y2)) x2=StrFix(x2,0,fractmax) y2=StrFix(y2,0,fractmax) carry=0 fract="" for p=fractmax to 2 by -1 f=strsub(x2,p,1) + strsub(y2,p,1) + carry if f > 9 f=f-10 carry=1 else carry=0 endif fract=strcat(f,fract) next ;Message("fract",fract) mainmax=max(StrLen(x1),StrLen(y1)) x1=strfixleft(x1,0,mainmax) y1=strfixleft(y1,0,mainmax) main="" for p=mainmax to 1 by -1 f=strsub(x1,p,1) + strsub(y1,p,1) + carry if f > 9 f=f-10 carry=1 else carry=0 endif main=strcat(f,main) next if carry==1 then main=strcat(1,main) result=strcat("#CURRENCY:",main,".",fract) return result #endfunction a1="#CURRENCY:4111111111111111111111111111111111111111111111111111114.22" a2="#CURRENCY:522222222222222222222222222222222222222222222222222222222222225.999" a3=CurrencyAdd(a1,a2) Message("Answer",a3)
Article ID: W15010
File Created: 2001:11:27:13:05:12
Last Updated: 2001:11:27:13:05:12