WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Conversion UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

UDF - Another number to words converter




If IsKeyDown(@CTRL) Then Debug(@ON)
If IsKeyDown(@SHIFT) Then DebugTrace(@ON,".\trace.txt")

IntControl(12,5,0,0,0)

If FileExist("debugon.chk") Then Debug(@ON)
If FileExist("debugtraceon.chk") Then DebugTrace(@ON,".\trace.txt")

;===================================================================================
:init

GoSub definefuncs

Decimals(2)

;===================================================================================
:main

z = 99481.17
y = num2txt(z)
Message(z,y)

z = 4481.00
y = num2txt(z)
Message(z,y)

z = 641.25
y = num2txt(z)
Message(z,y)

z = .75
y = num2txt(z)
Message(z,y)

z = .92
y = num2txt(z)
Message(z,y)

Exit


;===================================================================================
:definefuncs

#DefineFunction initnum()
aR     = ArrDimension(100)
aR[0]  = "ZERO"
aR[1]  = "ONE"
aR[2]  = "TWO"
aR[3]  = "THREE"
aR[4]  = "FOUR"
aR[5]  = "FIVE"
aR[6]  = "SIX"
aR[7]  = "SEVEN"
aR[8]  = "EIGHT"
aR[9]  = "NINE"
aR[10] = "TEN"
aR[11] = "ELEVEN"
aR[12] = "TWELVE"
aR[13] = "THIRTEEN"
aR[14] = "FOURTEEN"
aR[15] = "FIFTEEN"
aR[16] = "SIXTEEN"
aR[17] = "SEVENTEEN"
aR[18] = "EIGHTEEN"
aR[19] = "NINETEEN"
aR[20] = "TWENTY"
aR[21] = "TWENTY ONE"
aR[22] = "TWENTY TWO"
aR[23] = "TWENTY THREE"
aR[24] = "TWENTY FOUR"
aR[25] = "TWENTY FIVE"
aR[26] = "TWENTY SIX"
aR[27] = "TWENTY SEVEN"
aR[28] = "TWENTY EIGHT"
aR[29] = "TWENTY NINE"
aR[30] = "THIRTY"
aR[31] = "THIRTY ONE"
aR[32] = "THIRTY TWO"
aR[33] = "THIRTY THREE"
aR[34] = "THIRTY FOUR"
aR[35] = "THIRTY FIVE"
aR[36] = "THIRTY SIX"
aR[37] = "THIRTY SEVEN"
aR[38] = "THIRTY EIGHT"
aR[39] = "THIRTY NINE"
aR[40] = "FORTY"
aR[41] = "FORTY ONE"
aR[42] = "FORTY TWO"
aR[43] = "FORTY THREE"
aR[44] = "FORTY FOUR"
aR[45] = "FORTY FIVE"
aR[46] = "FORTY SIX"
aR[47] = "FORTY SEVEN"
aR[48] = "FORTY EIGHT"
aR[49] = "FORTY NINE"
aR[50] = "FIFTY"
aR[51] = "FIFTY ONE"
aR[52] = "FIFTY TWO"
aR[53] = "FIFTY THREE"
aR[54] = "FIFTY FOUR"
aR[55] = "FIFTY FIVE"
aR[56] = "FIFTY SIX"
aR[57] = "FIFTY SEVEN"
aR[58] = "FIFTY EIGHT"
aR[59] = "FIFTY NINE"
aR[60] = "SIXTY"
aR[61] = "SIXTY ONE"
aR[62] = "SIXTY TWO"
aR[63] = "SIXTY THREE"
aR[64] = "SIXTY FOUR"
aR[65] = "SIXTY FIVE"
aR[66] = "SIXTY SIX"
aR[67] = "SIXTY SEVEN"
aR[68] = "SIXTY EIGHT"
aR[69] = "SIXTY NINE"
aR[70] = "SEVENTY"
aR[71] = "SEVENTY ONE"
aR[72] = "SEVENTY TWO"
aR[73] = "SEVENTY THREE"
aR[74] = "SEVENTY FOUR"
aR[75] = "SEVENTY FIVE"
aR[76] = "SEVENTY SIX"
aR[77] = "SEVENTY SEVEN"
aR[78] = "SEVENTY EIGHT"
aR[79] = "SEVENTY NINE"
aR[80] = "EIGHTY"
aR[81] = "EIGHTY ONE"
aR[82] = "EIGHTY TWO"
aR[83] = "EIGHTY THREE"
aR[84] = "EIGHTY FOUR"
aR[85] = "EIGHTY FIVE"
aR[86] = "EIGHTY SIX"
aR[87] = "EIGHTY SEVEN"
aR[88] = "EIGHTY EIGHT"
aR[89] = "EIGHTY NINE"
aR[90] = "NINETY"
aR[91] = "NINETY ONE"
aR[92] = "NINETY TWO"
aR[93] = "NINETY THREE"
aR[94] = "NINETY FOUR"
aR[95] = "NINETY FIVE"
aR[96] = "NINETY SIX"
aR[97] = "NINETY SEVEN"
aR[98] = "NINETY EIGHT"
aR[99] = "NINETY NINE"

Return(aR)

#EndFunction


;===================================================================================
; num2txt

#DefineFunction num2txt(n)

; n is assumed to be a Valid Number with or without decimals
; right now n cannot exceed 999 million
; flag is either 0 or 1, if 1 return results as currency

aR = initnum()

;dollars = strfixleft(itemextract(1,n,"."),"0",5)
dollars = ItemExtract(1,n,".")
cents = ItemExtract(2,n,".")

wcents = StrCat(" AND ",cents,"/100 DOLLARS")

nlen = StrLen(dollars)

If dollars < 1
  wdollars = "NO"
  x = StrCat(wdollars,wcents)
Else
  If dollars < 100 
    wdollars = ar[dollars]
    x = StrCat(wdollars,wcents)
  Else
    If dollars < 1000
      wdollars = ar[StrSub(dollars,2,2)]
      whundreds = StrCat(ar[StrSub(dollars,1,1)]," HUNDRED ")
      x = StrCat(whundreds,wdollars,wcents)
    Else 
      If dollars < 10000
        wdollars = ar[StrSub(dollars,3,2)]
        whundreds = StrCat(ar[StrSub(dollars,2,1)]," HUNDRED ")
        wthousands = StrCat(ar[StrSub(dollars,1,1)]," THOUSAND ")
        x = StrCat(wthousands,whundreds,wdollars,wcents)
      Else
        If dollars < 100000
          wdollars = ar[Int(StrSub(dollars,4,2))]
          whundreds = StrCat(ar[StrSub(dollars,3,1)]," HUNDRED ")
          wthousands = StrCat(ar[StrSub(dollars,1,2)]," THOUSAND ")
          x = StrCat(wthousands,whundreds,wdollars,wcents)
        EndIf
      EndIf
    EndIf
  EndIf
EndIf

Return(x)

#EndFunction


Return


Article ID:   W16242
File Created: 2004:03:30:15:43:32
Last Updated: 2004:03:30:15:43:32