Re: Help w/ this lit'l function
Posted in 1996
Hannah Sobie Fiabema, molten keyboard in hand, chimes in with: > > Gurus, > I am having a little proble w/ this function. It is SUPPOSED to > accept an argument of type Money, and return the ascii equivalent > minus the dollar sign and decimal point. Everything almost works except > it is NOT returning the Cents portion of the argument. > Thanks for any and all help. Here is the code: [ Le code be le snipped ] Assuming (bad, I know, but...) that what you want is to convert 1234.56 into 123456 then I'd say that you are going about the problem the proverbial "hard way". Try this out and see if it is any better. FUNCTION MoneyToString(MoneyAmt) DEFINE MoneyAmt Money(12,2), MoneyStr char(20), WrkAmt Decimal(12,0) LET WrkAmt=MoneyAmt*100 LET MoneyStr=WrkAmt USING "<<<<<<<<<<<<" RETURN MoneyStr END FUNCTION Simply put, it eliminates the decimal point by multiplying the amount by 100 to shift the entire value above the decimal point, and then just uses the USING statement to left justify your number. Hope this helps, Will Hartung (villy@collinscomp.com)