FUNCTION Amt2Words PARAMETER nTrAmt lThousands = nTrAmt >= 1000 gcAmtStr = STR(nTrAmt,9,2) gcOneStr = 'One Two Three Four Five Six Seven Eight Nine Ten Eleven Twelve Thirteen Fourteen Fifteen Sixteen SeventeenEighteen Nineteen' gcTenStr = 'Twenty Thirty Forty Fifty Sixty SeventyEighty Ninety' cAmtInWords = '' IF lThousands IF DigitValue(1,1) > 0 Add2WordStr(SUBSTR(gcOneStr,DigitValue(1,1)*9-8,9)) Add2WordStr('Hundred') ENDIF IF DigitValue(2,1) > 1 Add2WordStr(SUBSTR(gcTenStr,(DigitValue(2,1)-1)*7-6,7)) IF DigitValue(3,1) > 0 Add2WordStr(SUBSTR(gcOneStr,DigitValue(3,1)*9-8,9)) ENDIF ELSE IF DigitValue(2,2) > 0 Add2WordStr(SUBSTR(gcOneStr,DigitValue(2,2)*9-8,9)) ENDIF ENDIF Add2WordStr('Thousand') ENDIF IF DigitValue(4,1) > 0 Add2WordStr(SUBSTR(gcOneStr,DigitValue(4,1)*9-8,9)) Add2WordStr('Hundred') ENDIF IF DigitValue(5,1) > 1 Add2WordStr(SUBSTR(gcTenStr,(DigitValue(5,1)-1)*7-6,7)) IF DigitValue(6,1) > 0 Add2WordStr(SUBSTR(gcOneStr,DigitValue(6,1)*9-8,9)) ENDIF ELSE IF DigitValue(5,2) > 0 Add2WordStr(SUBSTR(gcOneStr,DigitValue(5,2)*9-8,9)) ENDIF ENDIF IF nTrAmt = 0 cAmtInWords = 'Zero ' ENDIF cAmtInWords = cAmtInWords + 'dollars and ' + SUBSTR(gcAmtStr,8,2) + ' cents ' + REPLICATE('*',80) RETURN cAmtInWords FUNCTION DigitValue PARAMETER mPOS,mLEN RETURN VAL(SUBSTR(gcAmtStr,mPOS,mLEN)) FUNCTION Add2WordStr PARAMETER mSTRING cAmtInWords = cAmtInWords + ALLTRIM(mSTRING)+' ' RETURN .T.