Use a combination of the VdB functions Stuff() and at() to replace
"dollar(s)" with "pound(s)" and "cent(s)" with "pen(ce/ny)"
Andy
In article <34932ae7...@news.mvillage.com>, br...@mvillage.com
I believe that the dUFLP code library available at this site...
http://ourworld.compuserve.com/homepages/KMayer/DBASE.HTM
contains a routine that will do the trick.
____
Bowen Moursund
bowen...@nerds.com
http://www.mindspring.com/~bowenm/datatech.htm
>I am writing a check writing module for a business management package.
>Does anyone have any suggestions how I can get VDB to interpret the
>numeric dollar value entered in the amount field into english text
The following function comes from an old Clipper app. I had kicking
around. The syntax is not exactly one to one, but conversion should
not be too difficult or time consuming. If nothing else, it gives you
a model to work from :-) Hope it helps.
func numwords
SETCOLOR("B/W")
camt=""
STORE " ONE TWO THREEFOUR FIVE SIX SEVENEIGHTNINE " TO ones
STORE "TEN ELEVEN TWELVE THIRTEEN FOURTEEN FIFTEEN SIXTEEN
"+;
"SEVENTEENEIGHTEEN NINETEEN " TO teen
STORE "TWENTY THIRTY FORTY FIFTY SIXTY SEVENTYEIGHTY NINETY" TO
tens
cnum=LEFT(STR(mamt,9,2),6)
IF LEFT(cnum,1)>" "
camt=RTRIM(SUBSTR(ones,VAL(LEFT(cnum,1))*5+1,5))+" HUNDRED "
ENDIF
DO CASE
CASE SUBSTR(cnum,2,1)>"1"
camt=camt+RTRIM(SUBSTR(tens,VAL(SUBSTR(cnum,2,1))*7-13,7))
IF SUBSTR(cnum,3,1)>"0"
camt=camt+"-"+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,3,1))*5+1,5))
ENDIF
camt=camt+" THOUSAND "
CASE SUBSTR(cnum,2,1)="1"
camt=camt+RTRIM(SUBSTR(teen,VAL(SUBSTR(cnum,3,1))*9+1,9))+" THOUSAND "
CASE SUBSTR(cnum,2,2)="00"
camt=camt+"THOUSAND "
CASE SUBSTR(cnum,3,1)>" "
camt=camt+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,3,1))*5+1,5))+" THOUSAND "
ENDCASE
IF SUBSTR(cnum,4,1)>"0"
camt=camt+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,4,1))*5+1,5))+" HUNDRED "
ENDIF
DO CASE
CASE SUBSTR(cnum,5,1)>"1"
camt=camt+RTRIM(SUBSTR(tens,VAL(SUBSTR(cnum,5,1))*7-13,7))
IF RIGHT(cnum,1)>"0"
camt=camt+"-"+RTRIM(SUBSTR(ones,VAL(RIGHT(cnum,1))*5+1,5))
ENDIF
CASE SUBSTR(cnum,5,1)="1"
camt=camt+RTRIM(SUBSTR(teen,VAL(RIGHT(cnum,1))*9+1,9))
CASE RIGHT(cnum,2)=" 0"
camt="ZERO"
OTHERWISE
camt=camt+RTRIM(SUBSTR(ones,VAL(RIGHT(cnum,1))*5+1,5))
ENDCASE
cents=RIGHT(STR(mamt,9,2),2)
camt=RTRIM(camt)+" AND "+cents+"/100 DOLLARS"
IF tamt > 0
@ 11,4 SAY SPACE(74)
@ 12,10 SAY SPACE(30)
ENDIF
string = SPACE(62)
length = LEN(camt)
IF length > 75
counter = 74
DO WHILE .NOT. SUBSTR(camt,counter,1) $ " -"
counter = counter - 1
ENDDO
word1 = LEFT(camt,counter)+LEFT(string,75-counter)
word2 = SUBSTR(camt,counter+1,length-counter)
@ 11,4 SAY word1
@ 12,10 SAY word2
ELSE
word1 = camt + LEFT(string,75-length)
@ 11,4 SAY word1
ENDIF
SETCOLOR("W+/B")
RETURN
--
"Reply to" address is bot fodder- use:
wacoppin at king dot igs dot net
----
"We have reached the sad age when minds,
and not just houses, can be broken and
entered." - The New Yorker
Below is a function i wrote a couple years ago that does exactly what you
want. It should work with any version of dBASE for DOS or Windows. Enjoy!
FUNCTION Str2Num
PARAMETERS cStr
PRIVATE i, c, nRet, nLen, cTemp, cPoint
nRet = 0
IF TYPE("cStr") == "C"
nLen = 0
cTemp = ""
cPoint = SET("POINT")
c = ""
i = 0
cStr = LTRIM(RTRIM(cStr))
nLen = LEN(cStr)
FOR i = 1 TO nLen
c = SUBSTR(cStr, i, 1)
IF ((c >= "0") .AND. (c <= "9")) .OR. (c = cPoint) .OR. (c =
"-")
cTemp = cTemp + c
ENDIF
ENDFOR
nRet = VAL(cTemp)
ENDIF
RETURN nRet
David Veale wrote in message <674cjd$js...@newslist.borland.com>...
David Veale wrote:
--
Best regards, Samuel Malcuria
463 Castle
Geneva, New York 14456-1455
s...@mail.lynnet.com
home 315-789-1539
fax 315-789-1539
Hello sam!
Tuesday, December 16, 1997, sam wrote to All:
s> From: sam <s...@mail.lynnet.com>
s> Organization: lynnet
s> If you email me s...@lynnet.com I havethe code and will send to you. I
s> got it from Borland dbase news letter.
Is it possible to send the code also to me?
Regards, Henk
--
hdeu...@bundy.xs4all.nl
Tom Lake
>>I am writing a check writing module for a business management package.
>>Does anyone have any suggestions how I can get VDB to interpret the
>>numeric dollar value entered in the amount field into English text