This is how I did it, after much effort, I could add. I wrote this under ColdFusion 4.5, so your mileage may vary.
The key breaks the numbers into 3-row fragments, then displays each piece with the corresponding addenum (million, thousands, etc.) and, of course, deals with random zeros and numbers in adolescence. The first lists can be used to change languages, but require that the order is correct (i.e., first record = 1). This was for verification, where the figure was to be written out in English, so the set of variables is “verification”. The variable you are converting is a digit named "check_amount".
I apologize for the lousy code - I'm a designer, not a programmer. There are so many recurring sections that need to be reorganized, but they are designed to work with leading zeros and teens, mostly.
Third editing is lovely, I suppose. This final (working) version now correctly processes zero dollars.
<cfoutput><cfif IsNumeric(check_amount)> <cfparam name="write_single" default="one,two,three,four,five,six,seven,eight,nine, "> <cfparam name="write_double" default=" ,twenty,thirty,fourty,fifty,sixty,seventy,eighty,ninety"> <cfparam name="teens" default="11,12,13,14,15,16,17,18,19"> <cfparam name="teens_written" default="eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen"> <cfparam name="triplet_after" default="hundred, thousand, million, billion, trillion, quadrillion, quintillion, hexillion, heptillion, octillion, nonillion, decillion, unodecillion, duodecillion"> <cfset x=#ListLen(DecimalFormat(check_amount))#> <cfloop list="#DecimalFormat(check_amount)#" index="trips" delimiters=","> <cfif #Evaluate(Int(trips))# NEQ "0"> <cfif Len(Int(trips)) EQ "3"> <cfif mid(Int(trips), 1, 1) EQ "0"> <cfif #ListFind(teens, right(Int(trips), 2), ',')# NEQ "0"> #listGetAt(teens_written, ListFind(teens, right(int(trips), 2), ','), ',')# <cfelse> #listGetAt(write_double, mid(Int(trips), 2, 1), ',')# <cfif mid(Int(trips), 3, 1) NEQ "0"> #listGetAt(write_single, mid(Int(trips), 3, 1), ',')# </cfif> </cfif> <cfelse> #listGetAt(write_single, mid(Int(trips), 1, 1), ',')# #listGetAt(triplet_after, 1, ',')# </cfif> <cfif mid(trips, 2, 1) NEQ "0"> <cfif #ListFind(teens, right(Int(trips), 2), ',')# NEQ "0"> #listGetAt(teens_written, ListFind(teens, right(int(trips), 2), ','), ',')# <cfelse> #listGetAt(write_double, mid(Int(trips), 2, 1), ',')# <cfif mid(trips, 3, 1) NEQ "0"> #listGetAt(write_single, mid(Int(trips), 3, 1), ',')# </cfif> </cfif> <cfelse> <cfif mid(trips, 3, 1) NEQ "0"> #listGetAt(write_single, mid(Int(trips), 3, 1), ',')# </cfif> </cfif> <cfelseif Len(Int(trips)) EQ "2" AND mid(Int(trips), 1, 1) NEQ "0"> <cfif #ListFind(teens, right(Int(trips), 2), ',')# NEQ "0"> #listGetAt(teens_written, ListFind(teens, right(int(trips), 2), ','), ',')# <cfelse> #listGetAt(write_double, mid(Int(trips), 1, 1), ',')# <cfif mid(trips, 2, 1) NEQ "0"> #listGetAt(write_single, mid(Int(trips), 2, 1), ',')# </cfif> </cfif> <cfelseif Len(Int(trips)) EQ 1 AND mid(int(trips), 1, 1) NEQ "0"> #listGetAt(write_single, mid(Int(trips), 1, 1), ',')# </cfif> <cfif x NEQ "1">#listGetAt(triplet_after, x, ',')#</cfif> <cfelse> <cfif x EQ #ListLen(DecimalFormat(check_amount))#> No </cfif> </cfif> <cfset x=x-1> </cfloop> Dollars and <sup>#right(DecimalFormat(check_amount), 2)#</sup>/<sub>100</sub> cents</p> </cfif></cfoutput>