bradm98 Posted July 1, 2004 Posted July 1, 2004 I'm trying to create a calculated field that will display a text string description of a number in another field. For example, 124.1 would result in "One Hundred Twenty-Four and One Tenth." I could swear I'd seen a very similar example on these forums (for a checkbook type application I believe), but my searches didn't turn up anything. Before trying to reinvent the wheel, I figured I'd see if anyone could point me in the right direction. Any help would be greatly appreciated! Edit: still using FMP5.5
Lee Smith Posted July 1, 2004 Posted July 1, 2004 I could post a calculation that would do this, but it is such a long one, I'll point you to a file that show how this instead. Take a look around the site while you are there, it is a great resource. Number to Words By: Steve Davis URL: http://www.fmfiles.com/tnt1.html HTH Lee
bradm98 Posted July 1, 2004 Author Posted July 1, 2004 Thanks so much, Lee, for the quick response. This will get me 90% of the way towards my goal. I've bookmarked the site for future reference.
Newbies Ivory Kid Posted January 3, 2005 Newbies Posted January 3, 2005 Are these files still available on that website? I can't seem to download them? http://www.fmfiles.com/tnt1.html "CheckText" - ftp://ftp.fmfiles.com/download/devhaven/tipstricks/calcs/CHECKTXT.zip "Dollars" - ftp://ftp.fmfiles.com/download/devhaven/tipstricks/calcs/Dollars.zip "No. To Word" - ftp://ftp.fmfiles.com/download/devhaven/tipstricks/calcs/NoToWord.fp3.zip I cannot connect to the FTP server. Anyone have these files handy or know where I can find something similar? Thanks, Erik
Lee Smith Posted January 3, 2005 Posted January 3, 2005 Don't know what is going on with www.fmfiles.com today, very usual for them to be down. Here is another file that does it all too. "Dollars to Text"
Transmasco Posted January 9, 2005 Posted January 9, 2005 For those of us that use FMP7, we don't need all those fields from the old calculation. We just need to establish the same concept in a Let function as follows: _____________copy from here________________ Let([ Millions=Int(Amount/1000000); Thousands=Int((Amount-(Millions * 1000000 ))/1000); Hundreds=Int(Mod(Amount;1000)); Cents=Round((Amount-Int(Amount))*100 +.00005; 2); Millions Text=Choose(Int(Millions/100) ;"";"One";"Two";"Three";"Four";"Five";"Six";"Seven";"Eight";"Nine") & If(Int(Millions/100) > 0;" Hundred ";"") & Choose(Int(Mod(Millions;100)/10);"";"";"Twenty ";"Thirty ";"Forty ";"Fifty"; "Sixty ";"Seventy ";"Eighty ";"Ninety ") & Choose(If(Mod(Millions;100) >= 20;Mod(Millions;10); Mod(Millions;100));""; "One " ;"Two " ;"Three " ;"Four " ;"Five " ;"Six " ;"Seven " ;"Eight ";"Nine " ; "Ten " ;"Eleven " ;"Twelve " ;"Thirteen " ;"Fourteen " ;"Fifteen ";"Sixteen " ; "Seventeen " ;"Eighteen " ;"Nineteen ") & If(Millions > 0;"Million ";""); Thousands Text=Choose(Int(Thousands/100);"";"One";"Two";"Three";"Four";"Five";"Six"; "Seven";"Eight";"Nine") & If(Int(Thousands/100) > 0;" Hundred ";"") & Choose(Int(Mod(Thousands;100)/10);"";"";"Twenty ";"Thirty ";"Forty";"Fifty "; "Sixty ";"Seventy ";"Eighty ";"Ninety ") & Choose(If(Mod(Thousands;100) >= 20;Mod(Thousands;10);Mod(Thousands;100)); "";"One " ;"Two " ;"Three " ;"Four " ;"Five " ;"Six " ;"Seven " ;"Eight ";"Nine " ; "Ten " ;"Eleven " ;"Twelve " ;"Thirteen " ;"Fourteen " ;"Fifteen ";"Sixteen " ; "Seventeen " ;"Eighteen " ;"Nineteen ") & If(Thousands > 0;"Thousand ";""); Hundreds Text=Choose(Int(Hundreds/100);"";"One";"Two";"Three";"Four";"Five";"Six"; "Seven";"Eight";"Nine") & If(Int(Hundreds/100) > 0;" Hundred ";"") & Choose(Int(Mod(Hundreds;100)/10);"";"";"Twenty ";"Thirty ";"Forty";"Fifty "; "Sixty ";"Seventy ";"Eighty ";"Ninety ") & Choose(If(Mod(Hundreds;100) >= 20;Mod(Hundreds;10);Mod(Hundreds;100)); "";"One " ;"Two " ;"Three " ;"Four " ;"Five " ;"Six " ;"Seven " ;"Eight ";"Nine " ; "Ten " ;"Eleven " ;"Twelve " ;"Thirteen " ;"Fourteen " ;"Fifteen ";"Sixteen " ; "Seventeen " ;"Eighteen " ;"Nineteen ") & If(Amount < 1;"No Dollars"; If(Amount < 2;"Dollar";"Dollars")) & " & "; Cents Text=Case(Mod(Cents;100) = 0; "00/100"; Mod(Cents;100) < 10; "0" & Mod(Cents;100); Mod(Cents;100) & "/100")]; Millions Text & Thousands Text & Hundreds Text & Cents Text) ______________copy to here____________________ Works like a charm! I'm actually working on the Spanish version of it. Spanish tends to be a bit trickier since hundreds=100="cien" and hundreds=101 and up="ciento" and hundreds=200 and up="cientos". I'll post the spanish version of it when I finish it. Just thought I'd share. BTW: IF(UserDevelopingLargeSolution AND UserHasFMP7Developer; UserCanTurnThisCalcIntoACustomFunction; NeverMind)
-Queue- Posted January 11, 2005 Posted January 11, 2005 And there's the version I posted back in October that's also streamlined for 7. It doesn't go up to millions, but that's not too difficult to change. Case( not IsEmpty(GetAsNumber(CheckAmount)); Let([ P = Position( CheckAmount; "."; 0; 1 ); C = GetAsNumber( Left( CheckAmount; Case( not P; Length(CheckAmount); P ) )); D1 = "One Two Three Four Five Six Seven Eight Nine"; D2 = "Eleven Twelve Thirteen Fourteen Fifteen Sixteen Seventeen Eighteen Nineteen"; D3 = "Ten Twenty Thirty Forty Fifty Sixty Seventy Eighty Ninety"; L = Length© ]; Case( L > 6; "INVALID"; Substitute( Case( L > 5; MiddleWords( D1; Left( C; 1 ); 1 ) & " hundred " ) & Case( L > 4; Let([ C = Right( C; 5 ); T = Left( C; 1 ); O = Middle( C; 2; 1 ) ]; Case( not O; Case( T; MiddleWords( D3; T; 1 ) ); T + not T = 1; MiddleWords( Case( T; D2; D1 ); O; 1 ); MiddleWords( D3; T; 1 ) & "-" & MiddleWords( D1; O; 1 ) ) & " Thousand" & Case( Middle( C; 3; 1 ); "," ) & " " ) ) & Case( L = 4; MiddleWords( D1; Left( C; 1 ); 1 ) & " Thousand" & Case( Middle( C; 2; 1 ); "," ) & " " ) & Case( L > 2; Let([ C = Right( C; 3 ); T = Left( C; 1 ) ]; Case( T; MiddleWords( D1; Left( C; 1 ); 1 ) & " hundred " ) ) ) & Case( L > 1; Let([ C = Right( C; 2 ); T = Left( C; 1 ); O = Right( C; 1 ) ]; Case( not O; Case( T; MiddleWords( D3; T; 1 ) ); T + not T = 1; MiddleWords( Case( T; D2; D1 ); O; 1 ); MiddleWords( D3; T; 1 ) & "-" & MiddleWords( D1; O; 1 ) ) ) ) & Case( L = 1 and C; MiddleWords( D1; C; 1 ) ) & Case( Int(GetAsNumber(CheckAmount)); " and " ) & Right( "00" & 100 * Round( CheckAmount; 2 ); 2 ) & "/100"; " "; " " ) ) ) ) 1
Lee Smith Posted January 11, 2005 Posted January 11, 2005 Wow JT, What do you have, a 40" screen or something. Lee
comment Posted January 11, 2005 Posted January 11, 2005 You should also cater for "rippling" round, e.g. 9.995
-Queue- Posted January 11, 2005 Posted January 11, 2005 No Lee, I just have the resolution set to 1280 x 1024. Good point, Comment. I'll let you take the liberty of tweaking it if you wish.
comment Posted January 11, 2005 Posted January 11, 2005 What's to tweak? Let ([ Amount = Round ( CheckAmount ; 2 ) ; ... Replace CheckAmount with Amount, and remove the Round() in the last round.
Transmasco Posted January 20, 2005 Posted January 20, 2005 Queue, I like your calc better I'm having a hard time breking it apart tho. Would you be so kind as to comment the calc so that it's a bit clearer to follow? Translating it to spanish is proving a bit to much for my brain. The main problem is that in spanish you say 100 as "hundred" and 101 as "hundreds one". Also, I have to have to entire text string for hundreds i.e. "One Hundred", "Two hundred",etc since in spanish each has its name, not just "ones" & "hundreds". Does that make any sense???
BobWeaver Posted January 21, 2005 Posted January 21, 2005 Hmm, this looks like another opportunity for a How-simple-can-this-get contest. Here is the formula I use: Let ( [ n=Int(checkamount);c=Round((Mod(checkamount;1)*100);0); Units="Xone Xtwo Xthree Xfour Xfive Xsix Xseven Xeight Xnine Xten Xeleven Xtwelve Xthirteen Xfourteen Xfifteen Xsixteen Xseventeen Xeighteen Xnineteen null"; Tens="null twentyX thirtyX fortyX fiftyX sixtyX seventyX eightyX ninetyX null"] ; Case(n>999999;"Invalid";Proper(Substitute(Substitute( Case(n>=100000; MiddleWords(Units;Int(n/100000);1)&" Hundred ";"")& Case(Mod(n;100000)>=20000;MiddleWords(Tens;Int(Mod(n;100000)/10000);1) ;"")& Case(n>=1000; MiddleWords(Units;Int(Mod(n;10000*((Mod(n;100000)<20000)+1))/1000);1)& " Thousand ";"")& Case(Mod(n;1000)>=100; MiddleWords(Units;Int(Mod(n;1000)/100);1)&" Hundred ";"")& Case(Mod(n;100)>=20; MiddleWords(Tens;Int(Mod(n;100)/10);1);"")& Case(Mod(n;100)>=1; MiddleWords(Units;Mod(n;10*((Mod(n;100)<20)+1));1) ;"");"XX";"-");"X";"") )&" and "&c&"/100")) Like Queue's formula, this one only goes up to 999999.99, but can also be easily extended. The purpose of the X's is to simplify the correct hyphenation of numbers like "Twenty-seven." Unfortunately FM7s Proper() function does not correctly capitalize hyphenated words (it produces Twenty-Seven instead of Twenty-seven). I have another version of this formula that corrects for it, but I haven't thoroughly tested it yet. BTW, This is modified from a version that I used with FM5/6. Instead of the "Let" assignment, I used two global fields for Tens and Units, in order to keep the formula short. So, it's easy to convert into a FM5/6 compatible version. Oh yeah, Queue, what rules do you use for adding commas? I note that your formula produces: 8111.33 -> Eight Thousand, One hundred Eleven and 33/100 (comma after the 1000's) 8011.33 -> Eight Thousand Eleven and 33/100 (no comma) I didn't include commas in my formula.
comment Posted January 21, 2005 Posted January 21, 2005 1. Like Queue's formula, yours will break with 1.995. Change n to Int ( Round ( checkamount ; 2 ) ), and c to ... (can't test it now, but the rounding needs to be done first) ... I think. 2. This is nitpicking, but when 0 < checkamount < 1 - either provide for the zero, or get rid of the "and".
BobWeaver Posted January 21, 2005 Posted January 21, 2005 Hi Comment, Thanks for pointing out the problem with amounts under a dollar. I normally keep the fractional part out of the calculation and append it on as necessary. I just tossed it into the formula without checking carefully. I also noticed another error resulting from my sloppy typing. Here is the corrected (I think) formula: Let ( [ n=Int(Round(checkamount;2));c=Mod(Round(checkamount;2)*100;100); Units="null Xone Xtwo Xthree Xfour Xfive Xsix Xseven Xeight Xnine Xten Xeleven Xtwelve Xthirteen Xfourteen Xfifteen Xsixteen Xseventeen Xeighteen Xnineteen null"; Tens="null twentyX thirtyX fortyX fiftyX sixtyX seventyX eightyX ninetyX null"] ; Case(n>999999;"Invalid"; Substitute(Substitute(Substitute(Proper(Substitute(Substitute(Substitute( Case(n>=100000; MiddleWords(Units;1+Int(n/100000);1)&" Hundred ";"")& Case(Mod(n;100000)>=20000;MiddleWords(Tens;Int(Mod(n;100000)/10000);1) ;"")& Case(n>=1000; MiddleWords(Units;1+Int(Mod(n;10000*((Mod(n;100000)<20000)+1))/1000);1)& " Thousand"&Left(",";Mod(n;1000))&" ";"")& Case(Mod(n;1000)>=100; MiddleWords(Units;1+Int(Mod(n;1000)/100);1)&" Hundred ";"")& Case(Mod(n;100)>=20; MiddleWords(Tens;Int(Mod(n;100)/10);1);"")& Case(Mod(n;100)>=1; MiddleWords(Units;1+Mod(n;10*((Mod(n;100)<20)+1));1) ;"") ;"null";"");"XX";"Z");"X";""));"z";"-");" ";" ");" ";" ") &Case(n;" and ";"")&Right("00"&c;2)&"/100")) This also removes double spaces between words, fixes the capitalized hypenated word problem and adds a comma after the 1000's when necessary.
-Queue- Posted January 21, 2005 Posted January 21, 2005 Hi Bob. If the amount contains thousands and hundreds, then I would use a commma. Othewise I wouldn't. It would be similar for millions. E.g. Four million, two hundred twenty-three thousand, six hundred fifteen Four million, two hundred ten Four million three
BobWeaver Posted January 21, 2005 Posted January 21, 2005 Okay, I was just curious. I did an internet search for rules of punctuation for numbers written in words. I only found a couple of documents. One didn't use commas at all in their example. Another document from Australia recommended using commas in all cases, as long as there were more words following.
-Queue- Posted January 21, 2005 Posted January 21, 2005 I think I just write it the way I would say it, putting commas in where I would pause. I've seen it done several ways. This one is just my preference. I never really thought about it, though, until you asked.
Transmasco Posted January 22, 2005 Posted January 22, 2005 Queue, I'm really sorry to bother you but I REALLY need your help!! I've taken your calc, tweaked it and came up with this: BTW, "zValor" = the amount Case( not IsEmpty(GetAsNumber(zValor)); Let([ P = Position( zValor; "."; 0; 1 ); C = GetAsNumber( Left( zValor; Case( not P; Length(zValor); P ) )); D1 = "Uno Dos Tres Cuatro Cinco Seis Siete Ocho Nueve"; D2 = "Once Doce Trece Catorce Quince Dieciseis Diecisiete Dieciocho Diecinueve"; D3 = "Diez Veinte Treinta Cuarenta Cincuenta Sesenta Setenta Ochenta Noventa"; D4 = "Ciento Doscientos Trescientos Cuatrocientos Quinientos Seiscientos Setecientos Ochocientos Novecientos"; L = Length© ]; Case( L > 6; "INVALIDO"; Substitute( //esto calcula los cientos de miles Case( L > 5; MiddleWords( D4; Left( C; 1 ); 1 )&" ") & //esto calcula las decenas de miles Case( L > 4; Let([ C = Right( C; 5 ); T = Left( C; 1 ); O = Middle( C; 2; 1 ) ]; Case( not O; Case( T; MiddleWords( D3; T; 1 ) ); T + not T = 1; MiddleWords( Case( T; D2; D1 ); O; 1 ); MiddleWords( D3; T; 1 ) & " y " & MiddleWords( D1; O; 1 ) ) & " Mil" & Case( Middle( C; 3; 1 ); "," ) & " " ) ) & Case( L = 4; MiddleWords( D1; Left( C; 1 ); 1 ) & " Mil" & Case( Middle( C; 2; 1 ); "," ) & " " ) & Case( L > 2; Let([ C = Right( C; 3 ); T = Left( C; 1 ) ]; Case( T; MiddleWords( D4; Left( C; 1 ); 1 )&" " ) ) ) & Case( L > 1; Let([ C = Right( C; 2 ); T = Left( C; 1 ); O = Right( C; 1 ) ]; Case( not O; Case( T; MiddleWords( D3; T; 1 ) ); T + not T = 1; MiddleWords( Case( T; D2; D1 ); O; 1 ); MiddleWords( D3; T; 1 ) & " y " & MiddleWords( D1; O; 1 ) ) ) ) & Case( L = 1 and C; MiddleWords( D1; C; 1 ) ) & //esto calcula los centavos Case( Int(GetAsNumber(zValor)); " con " ) & Right( "00" & 100 * Round( zValor; 2 ); 2 ) & "/100"; " "; " " ) ) ) ) It works great, except for the following situations: 1) When the amount is exactly 100, I need it to write "cien" not "ciento". 2) When the thousands place = 1 (i.e. 1,### or #01,###) I need it to write "un" (i.e. "un mil") not "uno" (i.e. "uno mil"). 3) As with the 100 case in 1), when the hundred thousands = 100 (i.e. 100,###) I need it to write "cien" (i.e. "cien mil") not "ciento" (i.e. "ciento mil"). Please help me, I'm going NUTZ with this!
BobWeaver Posted January 23, 2005 Posted January 23, 2005 A couple of years ago I worked on both a French and Spanish version of this. I tried to come up with a general formula that could be quickly converted from one language to another. Although not very elegant, I concluded that it was easiest in the long run to provide the text for all numbers from 1 to 100 and then the text for 100, 200, 300..900. And then, use the substitute function with some search and replace strings to correct certain special cases. It is good for numbers up to 999,999,999. This is the FM 7 version of what I came up with: Let ( [ n=Int(Round(checkamount;2)); Utxt=Substitute(".uno.dos.tres.cuatro.cinco.seis.siete.ocho.nueve.diaz.once.doce.trece.catorce.quince.dieciseis.diecisiete.dieciocho.diecinueve."& "veinte.veinteuno.veintedos.veintetres.veintecuatro.veintecinco.veinteseis.veintesiete.veinteocho.veintenueve."& "treinta.treinta y uno.treinta y dos.treinta y tres.treinta y cuatro.treinta y cinco.treinta y seis.treinta y siete.treinta y ocho.treinta y nueve."& "cuarenta.cuarenta y uno.cuarenta y dos.cuarenta y tres.cuarenta y cuatro.cuarenta y cinco.cuarenta y seis.cuarenta y siete.cuarenta y ocho.cuarenta y nueve."& "cincuenta.cincuenta y uno.cincuenta y dos.cincuenta y tres.cincuenta y cuatro.cincuenta y cinco.cincuenta y seis.cincuenta y siete.cincuenta y ocho.cincuenta y nueve."& "sesenta.sesenta y uno.sesenta y dos.sesenta y tres.sesenta y cuatro.sesenta y cinco.sesenta y seis.sesenta y siete.sesenta y ocho.sesenta y nueve."& "setenta.setenta y uno.setenta y dos.setenta y tres.setenta y cuatro.setenta y cinco.setenta y seis.setenta y siete.setenta y ocho.setenta y nueve."& "ochenta.ochenta y uno.ochenta y dos.ochenta y tres.ochenta y cuatro.ochenta y cinco.ochenta y seis.ochenta y siete.ochenta y ocho.ochenta y nueve."& "noventa.noventa y uno.noventa y dos.noventa y tres.noventa y cuatro.noventa y cinco.noventa y seis.noventa y siete.noventa y ocho.noventa y nueve.";".";"
Transmasco Posted January 24, 2005 Posted January 24, 2005 Queue, I hope you are a handsome man...cause I'm about to KISS YOU! ~smooooooooch~ Thank you so much, it works beautifully! edit: I tweaked the bold part so the #01,### parts worked. Thanks a million Queue! Now to share with the masses: Case( not IsEmpty(GetAsNumber(zValor)); Let([ P = Position( zValor; "."; 0; 1 ); C = GetAsNumber( Left( zValor; Case( not P; Length(zValor); P ) )); D1 = "Uno Dos Tres Cuatro Cinco Seis Siete Ocho Nueve"; D2 = "Once Doce Trece Catorce Quince Dieciseis Diecisiete Dieciocho Diecinueve"; D3 = "Diez Veinte Treinta Cuarenta Cincuenta Sesenta Setenta Ochenta Noventa"; D4 = "Ciento Doscientos Trescientos Cuatrocientos Quinientos Seiscientos Setecientos Ochocientos Novecientos"; L = Length© ]; Case( L > 6; "INVALIDO"; TrimAll( Substitute( //esto calcula los cientos de miles Case( L > 5; Case( Left( C; 3 ) = 100; "Cien"; MiddleWords( D4; Left( C; 1 ); 1 ) ) & " " ) & //esto calcula las decenas de miles Case( L > 4; Let([ C = Right( C; 5 ); T = Left( C; 1 ); O = Middle( C; 2; 1 ) ]; Case( not O; Case( T; MiddleWords( D3; T; 1 ) ); T + not T = 1; MiddleWords( Case( T; D2; Case( Middle( C;2;1)=
Newbies bkny5 Posted January 24, 2005 Newbies Posted January 24, 2005 Hi, I've been searching these posts, but have not found any answers, we are having the opposite problem. We are teachers in a middle school and need to convert letter grades to numbers, which are thenused in other calculations. We have figured out how to do this using the CASE function, but it is time consuming for the number of fields we have for every content area. Is there another way?
-Queue- Posted January 24, 2005 Posted January 24, 2005 Sorry to disappoint, Robert, but I'm more like a dorky Jude Law or a less-cool Tarantino. Thanks anyway! BK, this thread is about currency. It sounds like you are talking about converting an alpha character to a number. If this is the case, how do you want the letters to be converted, i.e. what range constitutes an A, B, etc.?
The Shadow Posted May 5, 2007 Posted May 5, 2007 I just thought I'd add a custom function version to this thread, it should be easy to localize, I would think. CheckWriting.zip
Quito Posted November 18, 2009 Posted November 18, 2009 Hi, Here's another Spanish "números a palabras" script (use Cálculo Sin almacenar en el campo): Case ( Total = 0 ; "" ; Total > 999999999; "Número fuera de rango." ; Let ( [millones = Int ( Total/10^6 ); miles = Int (Mod ( Total ; 10^6 )/10^3); cientos = Int ( Mod ( Total ; 10^3 ) ); centavos = Int ( (Total - Int ( Total ) ) * 100 )]; Choose ( Int ( millones/100 ); "";If ( millones = 100 ; "cien " ; "ciento " );"doscientos ";"trescientos ";"cuatrocientos ";"quinientos ";"seiscientos ";"setecientos ";"ochocientos ";"novecientos " ) & Case ( Mod ( millones ; 100 ) < 30 ; Choose ( Mod ( millones ; 100 ) ; "";"un ";"dos ";"tres ";"cuatro ";"cinco ";"seis ";"siete ";"ocho ";"nueve "; "diez ";"once ";"doce ";"trece ";"catorce ";"quince ";"dieciseis ";"diecisiete ";"dieciocho ";"diecinueve ";"veinte "; "veintiun ";"veintidos ";"veintitrés ";"veinticuatro ";"veinticinco ";"veintiseis ";"veintisiete ";"veintiocho ";"veintinueve " ); Choose ( Int ( Mod ( millones ; 100 ) / 10 ) ; "";"";"";"treinta ";"cuarenta ";"cincuenta ";"sesenta ";"setenta ";"ochenta ";"noventa ") & Choose ( Mod ( millones ; 10 ) ;"";"y un ";"y dos ";"y tres ";"y cuatro ";"y cinco ";"y seis ";"y siete ";"y ocho ";"y nueve ") ) & Case ( millones = 0 ; "" ; millones = 1 ; "millón "; "millones " ) & Choose ( Int ( miles/100 ); "";If ( miles = 100 ; "cien " ; "ciento " );"doscientos ";"trescientos ";"cuatrocientos ";"quinientos ";"seiscientos ";"setecientos ";"ochocientos ";"novecientos " ) & Case ( Mod ( miles ; 100 ) < 30 ; Choose ( Mod ( miles ; 100 ) ; "";"";"dos ";"tres ";"cuatro ";"cinco ";"seis ";"siete ";"ocho ";"nueve "; "diez ";"once ";"doce ";"trece ";"catorce ";"quince ";"dieciseis ";"diecisiete ";"dieciocho ";"diecinueve ";"veinte "; "veintiun ";"veintidos ";"veintitrés ";"veinticuatro ";"veinticinco ";"veintiseis ";"veintisiete ";"veintiocho ";"veintinueve " ); Choose ( Int ( Mod ( miles ; 100 ) / 10 ) ; "";"";"";"treinta ";"cuarenta ";"cincuenta ";"sesenta ";"setenta ";"ochenta ";"noventa ") & Choose ( Mod ( miles ; 10 ) ;"";"y un ";"y dos ";"y tres ";"y cuatro ";"y cinco ";"y seis ";"y siete ";"y ocho ";"y nueve ") ) & Case ( miles = 0 ; "" ; "mil " ) & Choose ( Int ( cientos/100 ); "";If ( cientos = 100 ; "cien " ; "ciento " );"doscientos ";"trescientos ";"cuatrocientos ";"quinientos ";"seiscientos ";"setecientos ";"ochocientos ";"novecientos " ) & Case ( Mod ( cientos ; 100 ) < 30 ; Choose ( Mod ( cientos ; 100 ) ; "";"un ";"dos ";"tres ";"cuatro ";"cinco ";"seis ";"siete ";"ocho ";"nueve "; "diez ";"once ";"doce ";"trece ";"catorce ";"quince ";"dieciseis ";"diecisiete ";"dieciocho ";"diecinueve ";"veinte "; "veintiun ";"veintidos ";"veintitrés ";"veinticuatro ";"veinticinco ";"veintiseis ";"veintisiete ";"veintiocho ";"veintinueve " ); Choose ( Int ( Mod ( cientos ; 100 ) / 10 ) ; "";"";"";"treinta ";"cuarenta ";"cincuenta ";"sesenta ";"setenta ";"ochenta ";"noventa ") & Choose ( Mod ( cientos ; 10 ) ;"";"y un ";"y dos ";"y tres ";"y cuatro ";"y cinco ";"y seis ";"y siete ";"y ocho ";"y nueve ") ) & Case ( Int ( Total ) = 1 ; "dólar"; Int ( Total ) = 0 ; "cero dólares "; "dólares" ) & Case( Int(GetAsNumber(Total)); " con " ) & Right( "00" & 100 * Round( Total; 2 ); 2 ) & "/100" & " centavos" ) )
Newbies pau valiente Posted January 7, 2010 Newbies Posted January 7, 2010 Hello everybody! First of all thank you all for the efforts on those formulas, it's a great help for novices like me! I'm learning a lot just reading those formulas piece by piece .... Thanks!!! I'm looking at all the options for the spanish one as is the one I'm interested and must say it works better for me the Quito's formula, it accepts higher numbers. I'm trying to do a version (please read the word "trying", as I'm super novice) for the spanish euro rules. As I want to learn I'll be doing it part by part. Just to note it, I'll try to: - Add the word "de" on the milions (as in 1.000.000 "un millón de euros" but not in the 1.000.001 "un millón un euro" - Also write in words the cents part, as in spain is like that: 10,25 "diez euros con veinticinco céntimos" - Also I would like to write down cents when they exist in the number, so 10 would be "diez euros" and 15,10 would be "quince euros con diez céntimos" There is a page that explains this very good (in spanish) http://buscon.rae.es/dpdI/SrvltGUIBusDPD?lema=cardinales I will keep posting the code I will work on and would appreciate your comments and help. Again, thank you so much! -
Newbies pau valiente Posted January 10, 2010 Newbies Posted January 10, 2010 Ok, here I paste the code as I have it now: - I added the cents as words too Still to resolve is to add the word "de" (a milion "de" euros) and just write "con céntimos" when there are cents on the number. I'll keep posting and sure asking! -D //falta añadir "un millón de euros" //falta eliminar céntimos si no los hay Case ( SalaryTotalNum = 0 ; "" ; SalaryTotalNum > 999999999; "Número fuera de rango." ; Let ( [millones = Int ( SalaryTotalNum/10^6 ); miles = Int (Mod ( SalaryTotalNum ; 10^6 )/10^3); cientos = Int ( Mod ( SalaryTotalNum ; 10^3 ) ); centimos = Int ( (SalaryTotalNum - Int ( SalaryTotalNum ) ) * 100)]; Choose ( Int ( millones/100 ); "";If ( millones = 100 ; "cien " ; "ciento " );"doscientos ";"trescientos ";"cuatrocientos ";"quinientos ";"seiscientos ";"setecientos ";"ochocientos ";"novecientos " ) & Case ( Mod ( millones ; 100 ) < 30 ; Choose ( Mod (millones ; 100 ) ; "";"un ";"dos ";"tres ";"cuatro ";"cinco ";"seis ";"siete ";"ocho ";"nueve "; "diez ";"once ";"doce ";"trece ";"catorce ";"quince ";"dieciséis ";"diecisiete ";"dieciocho ";"diecinueve "; "veinte ";"veintiún ";"veintidós";"veintitrés ";"veinticuatro ";"veinticinco ";"veintiséis ";"veintisiete ";"veintiocho ";"veintinueve " ); Choose ( Int ( Mod ( millones ; 100 ) / 10 ) ; "";"";"";"treinta ";"cuarenta ";"cincuenta ";"sesenta ";"setenta ";"ochenta ";"noventa ") & Choose ( Mod ( millones ; 10 ) ;"";"y un ";"y dos ";"y tres ";"y cuatro ";"y cinco ";"y seis ";"y siete ";"y ocho ";"y nueve ") ) & Case ( millones = 0 ; "" ; millones = 1 ; "millón "; "millones " ) & Choose ( Int ( miles/100 ); "";If ( miles = 100 ; "cien " ; "ciento " );"doscientos ";"trescientos ";"cuatrocientos ";"quinientos ";"seiscientos ";"setecientos ";"ochocientos ";"novecientos " ) & Case ( Mod ( miles ; 100 ) < 30 ; Choose ( Mod ( miles ; 100 ) ; "";"";"dos ";"tres ";"cuatro ";"cinco ";"seis ";"siete ";"ocho ";"nueve "; "diez ";"once ";"doce ";"trece ";"catorce ";"quince ";"dieciséis ";"diecisiete ";"dieciocho ";"diecinueve ";"veinte "; "veintiún ";"veintidós ";"veintitrés ";"veinticuatro ";"veinticinco ";"veintiséis ";"veintisiete ";"veintiocho ";"veintinueve " ); Choose ( Int ( Mod ( miles ; 100 ) / 10 ) ; "";"";"";"treinta ";"cuarenta ";"cincuenta ";"sesenta ";"setenta ";"ochenta ";"noventa ") & Choose ( Mod ( miles ; 10 ) ;"";"y un ";"y dos ";"y tres ";"y cuatro ";"y cinco ";"y seis ";"y siete ";"y ocho ";"y nueve ") ) & Case ( miles = 0 ; "" ; "mil " ) & Choose ( Int ( cientos/100 ); "";If ( cientos = 100 ; "cien " ; "ciento " );"doscientos ";"trescientos ";"cuatrocientos ";"quinientos ";"seiscientos ";"setecientos ";"ochocientos ";"novecientos " ) & Case ( Mod ( cientos ; 100 ) < 30 ; Choose ( Mod ( cientos ; 100 ) ; "";"un ";"dos ";"tres ";"cuatro ";"cinco ";"seis ";"siete ";"ocho ";"nueve "; "diez ";"once ";"doce ";"trece ";"catorce ";"quince ";"dieciséis ";"diecisiete ";"dieciocho ";"diecinueve ";"veinte "; "veintiún ";"veintidós ";"veintitrés ";"veinticuatro ";"veinticinco ";"veintiséis ";"veintisiete ";"veintiocho ";"veintinueve " ); Choose ( Int ( Mod ( cientos ; 100 ) / 10 ) ; "";"";"";"treinta ";"cuarenta ";"cincuenta ";"sesenta ";"setenta ";"ochenta ";"noventa ") & Choose ( Mod ( cientos ; 10 ) ;"";"y un ";"y dos ";"y tres ";"y cuatro ";"y cinco ";"y seis ";"y siete ";"y ocho ";"y nueve ") ) & Case ( Int ( SalaryTotalNum ) = 1 ; "euro"; Int ( SalaryTotalNum ) = 0 ; "cero euros "; "euros" ) & Case( Int(GetAsNumber(SalaryTotalNum)); " con " ) & Case ( Right( 100 * Round( SalaryTotalNum; 2 ); 2 ) < 30 ; Choose ( Right( 100 * Round( SalaryTotalNum; 2 ); 2 ) ; "";"un ";"dos ";"tres ";"cuatro ";"cinco ";"seis ";"siete ";"ocho ";"nueve "; "diez ";"once ";"doce ";"trece ";"catorce ";"quince ";"dieciséis ";"diecisiete ";"dieciocho ";"diecinueve ";"veinte "; "veintiún ";"veintidós ";"veintitrés ";"veinticuatro ";"veinticinco ";"veintiséis ";"veintisiete ";"veintiocho ";"veintinueve " ); Choose ( Int ( Right( 100 * Round( SalaryTotalNum; 2 ); 2 ) / 10 ) ; "";"";"";"treinta ";"cuarenta ";"cincuenta ";"sesenta ";"setenta ";"ochenta ";"noventa ") & Choose ( Right( 100 * Round( SalaryTotalNum; 2 ); 1 ) ;"";"y un ";"y dos ";"y tres ";"y cuatro ";"y cinco ";"y seis ";"y siete ";"y ocho ";"y nueve ") ) & "céntimos" ) )
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now