Code: Select all
/* Author: Bayron Landaverry
Maya Point Of Sale
6 Av. 3-26, zona 4
Chiquimula, Guatemala
Version: Clipper 5.3 (But it may run on other
versions with only a few
changes, I think it may, anyway)
Comments: Does not need external library's
Does not have color nor graphics, for
compatibility with your applications.
There is no guarantee on this application.
It can be used and distributed freely.
Please feel free to modify it.
*/
#INCLUDE "FiveWin.CH"
Function main()
Local nAmount := 0
MsgGet("Cantidad",,@nAmount)
Msginfo( ALLTRIM( STR(nAmount) ) + ":=" +NumToLet(nAmount) )
Return NIL
FUNCTION NumToLet(nAmount)
LOCAL NToL[29, 1]
NToL[ 1, 1] := "One "
NToL[ 2, 1] := "Two "
NToL[ 3, 1] := "Three "
NToL[ 4, 1] := "Four "
NToL[ 5, 1] := "Five "
NToL[ 6, 1] := "Six "
NToL[ 7, 1] := "Seven "
NToL[ 8, 1] := "Eight "
NToL[ 9, 1] := "Nine "
NToL[10, 1] := "Ten "
NToL[11, 1] := "Eleven "
NToL[12, 1] := "Twelve "
NToL[13, 1] := "Thirteen "
NToL[14, 1] := "Fourteen "
NToL[15, 1] := "Fifteen "
NToL[16, 1] := "Sixteen "
NToL[17, 1] := "Seventeen "
NToL[18, 1] := "Eighteen "
NToL[19, 1] := "Nineteen "
NToL[20, 1] := "Twenty "
NToL[21, 1] := "Thirty "
NToL[22, 1] := "Forty "
NToL[23, 1] := "Fifty "
NToL[24, 1] := "Sixty "
NToL[25, 1] := "Seventy "
NToL[26, 1] := "Eighty "
NToL[27, 1] := "Ninety "
NToL[28, 1] := "Hundred "
NToL[29, 1] := "Thousand "
*****Millions*******
nAmountL1 = Substr(Transform(nAmount, "9999999.99"), 1, 7)
nAmountL2 = Substr(nAmountL1, 1, 1)
nAmountL = IF(Val(nAmountL2) > 0, NToL[Val(nAmountL2), 1] +;
IF(Val(nAmountL2) > 1, "Millions ", "Million "), "")
*****Hundreds of thousands*********
nAmountL2 = Substr(nAmountL1, 2, 1)
nAmountL3 = Substr(nAmountL1, 3, 2)
nAmountL = nAmountL + IF(Val(nAmountL2) > 0, NToL[Val(nAmountL2), 1] +;
NToL[28, 1] + IF(Val(nAmountL3) > 0,;
"", NToL[29, 1]), "")
*****Tenths of thousands*********
nAmountL2 = Substr(nAmountL1, 3, 2)
nAmountL3 = Substr(nAmountL1, 3, 1)
nAmountL4 = Substr(nAmountL1, 4, 1)
nAmountL5 = Substr(nAmountL1, 2, 1)
nAmountL = nAmountL + IF(Val(nAmountL2) < 20 .AND. Val(nAmountL2) > 0,;
NToL[Val(nAmountL2), 1] + NToL[29, 1], "")
nAmountL = nAmountL + IF(Val(nAmountL2) > 19, NToL[(18 + ;
Val(nAmountL3)), 1] + IF(Val(nAmountL4) > 0,;
NToL[Val(nAmountL4), 1], "") + NToL[29, 1], "")
*****Hundreds*********
nAmountL2 = Substr(nAmountL1, 5, 1)
nAmountL3 = Substr(nAmountL1, 6, 2)
nAmountL = nAmountL + IF(Val(nAmountL2) > 0, NToL[Val(nAmountL2), 1] +;
NToL[28, 1], "")
*****Tenths*********
nAmountL2 = Substr(nAmountL1, 6, 2)
nAmountL3 = Substr(nAmountL1, 6, 1)
nAmountL4 = Substr(nAmountL1, 7, 1)
nAmountL = nAmountL + IF(Val(nAmountL2) < 20 .AND. Val(nAmountL2) > 0,;
NToL[Val(nAmountL2), 1], "")
nAmountL = nAmountL + IF(Val(nAmountL2) > 19, NToL[(18 + ;
Val(nAmountL3)), 1] + IF(Val(nAmountL4) > 0,;
NToL[Val(nAmountL4), 1], ""), "")
nAmountL = nAmountL + IF(nAmount > 1, "Dollars ", "Dollar " ) + "and " + Substr(Transform(nAmount, "9999999.99"), -2) + " Cts."
nAmountL = IF( nAmount <= 0, "Zero Dollars", nAmountL )
Return nAmountL