Menu
Ok. man..
this is a real challenge….
for me….
cause im not a serious coder….
but you are….!!!!
Ok..
this is to retrive numbers from a data base….
is a money format field….
now i have to write this number in other field… but..
in letters!!!!!
i remember to saw some simmilar script in other pages … but in fact i
don’t know where….
could anyone help me to find something to do this..
or if anyone has something simmilar… well… i will apreciate to
share it!!!!
thanks
Regards for all!!!!!
RT
The program referenced by konithomimo contains bugs.
[/QUOTE]
If you're going to give him something to start with, at least give him something worth starting with.[/QUOTE]
You say that you could write better code, so go ahead and do it.[/QUOTE]
<i>
</i>function pesotext(amt) {
var smallnums=new Array('cero ','un ','dos ','tres ','cuatro ',
'cinco ','seis ','siete ','ocho ','nueve ',
'diez ','once ','doce ','trece ','catorce ',
'quince ','dieciseis ','diecisiete ','dieciocho ','diecinueve ',
'veinte ','veintiún ','veintidós ','veintitrés ','veinticuatro ',
'veinticinco ','veintiséis ','veintisiete ','veintiocho ',
'veintinueve ');
var tens=new Array('error','error','error','treinta ','cuarenta ',
'cincuenta ','sesenta ','setenta ','ochenta ','noventa ');
var ones=new Array('','y un ','y dos ','y tres ','y cuatro ',
'y cinco ','y seis ','y siete ','y ocho ','y nueve ');
var hundreds=new Array(' ','ciento ','doscientos ','trescientos ',
'cuatrocientos ','quinientos ','seiscientos ','setecientos ',
'ochocientos ','novecientos ');
var work=Math.round(amt*100);
var os='';
if (work<0) {os='menos '; work=-work;}
if (work>1e15) return 'error';
var npart=new Array();
var nfact=new Array(100,100,10,100,10,100,10,100);
var p=0;
for (p=0; p<nfact.length; p++) {
npart[p]=work%nfact[p];
work=Math.round((work-npart[p])/nfact[p]) }
if (npart[7]<2) ;
else if (npart[7]<smallnums.length) os+=smallnums[npart[7]];
else os+=(tens[Math.round((npart[7]-(npart[7]%10))/10)]
+ones[npart[7]%10]);
if (npart[7]>0) os+='mil '
if (npart[6]!=1 || npart[5]) os+=hundreds[npart[6]];
else os+='cien ';
if (npart[5]==0) ;
else if (npart[5]<smallnums.length) os+=smallnums[npart[5]];
else os+=(tens[Math.round((npart[5]-(npart[5]%10))/10)]
+ones[npart[5]%10]);
if (npart[7] || npart[6]) os+='millones ';
else if (npart[5]) os+=(npart[5]==1?'millón ':'millones ');
if (npart[4]!=1 || npart[3]) os+=hundreds[npart[4]];
else os+='cien ';
if (npart[3]==0) ;
else if (!(npart[7] || npart[6] || npart[5] || npart[4])
&& npart[3]==1) ;
else if (npart[3]<smallnums.length) os+=smallnums[npart[3]];
else os+=(tens[Math.round((npart[3]-(npart[3]%10))/10)]
+ones[npart[3]%10]);
if (npart[4] || npart[3]) os+='mil ';
if (npart[2]!=1 || npart[1]) os+=hundreds[npart[2]];
else os+='cien ';
if (npart[1]==0) ;
else if (npart[1]<smallnums.length) os+=smallnums[npart[1]];
else os+=(tens[Math.round((npart[1]-(npart[1]%10))/10)]
+ones[npart[1]%10]);
if ((npart[7] || npart[6] || npart[5]) &&
!(npart[4] || npart[3] || npart[2] || npart[1]))
os+='de ';
if (npart[7] || npart[6] || npart[5]
|| npart[4] || npart[3] || npart[2]) os+='pesos';
else if (npart[1]) os+=(npart[1]==1?'peso':'pesos');
else os+='cero pesos';
if (npart[0]) { os+=' con ';
if (npart[0]<smallnums.length) os+=smallnums[npart[0]];
else os+=(tens[Math.round((npart[0]-(npart[0]%10))/10)]
+ones[npart[0]%10]);
os+=(npart[0]==1?'centavo':'centavos'); }
return os; }
<i>
</i>function pesotext(amt) {
var smallnums=new Array('cero ','un ','dos ','tres ','cuatro ',
'cinco ','seis ','siete ','ocho ','nueve ',
'diez ','once ','doce ','trece ','catorce ',
'quince ','dieciseis ','diecisiete ','dieciocho ','diecinueve ',
'veinte ','veintiún ','veintidós ','veintitrés ','veinticuatro ',
'veinticinco ','veintiséis ','veintisiete ','veintiocho ',
'veintinueve ');
var tens=new Array('error','error','error','treinta ','cuarenta ',
'cincuenta ','sesenta ','setenta ','ochenta ','noventa ');
var ones=new Array('','y un ','y dos ','y tres ','y cuatro ',
'y cinco ','y seis ','y siete ','y ocho ','y nueve ');
var hundreds=new Array(' ','ciento ','doscientos ','trescientos ',
'cuatrocientos ','quinientos ','seiscientos ','setecientos ',
'ochocientos ','novecientos ');
var work=Math.round(amt*100);
var os='';
if (work<0) {os='menos '; work=-work;}
if (work>1e15) return 'error';
var npart=new Array();
var nfact=new Array(100,100,10,100,10,100,10,100);
var p=0;
for (p=0; p<nfact.length; p++) {
npart[p]=work%nfact[p];
work=Math.round((work-npart[p])/nfact[p]) }
if (npart[7]<2) ;
else if (npart[7]<smallnums.length) os+=smallnums[npart[7]];
else os+=(tens[Math.round((npart[7]-(npart[7]%10))/10)]
+ones[npart[7]%10]);
if (npart[7]>0) os+='mil '
if (npart[6]!=1 || npart[5]) os+=hundreds[npart[6]];
else os+='cien ';
if (npart[5]==0) ;
else if (npart[5]<smallnums.length) os+=smallnums[npart[5]];
else os+=(tens[Math.round((npart[5]-(npart[5]%10))/10)]
+ones[npart[5]%10]);
if (npart[7] || npart[6]) os+='millones ';
else if (npart[5]) os+=(npart[5]==1?'millón ':'millones ');
if (npart[4]!=1 || npart[3]) os+=hundreds[npart[4]];
else os+='cien ';
if (npart[3]==0) ;
else if (!(npart[7] || npart[6] || npart[5] || npart[4])
&& npart[3]==1) ;
else if (npart[3]<smallnums.length) os+=smallnums[npart[3]];
else os+=(tens[Math.round((npart[3]-(npart[3]%10))/10)]
+ones[npart[3]%10]);
if (npart[4] || npart[3]) os+='mil ';
if (npart[2]!=1 || npart[1]) os+=hundreds[npart[2]];
else os+='cien ';
if (npart[1]==0) ;
else if (npart[1]<smallnums.length) os+=smallnums[npart[1]];
else os+=(tens[Math.round((npart[1]-(npart[1]%10))/10)]
+ones[npart[1]%10]);
if ((npart[7] || npart[6] || npart[5]) &&
!(npart[4] || npart[3] || npart[2] || npart[1]))
os+='de ';
if (npart[7] || npart[6] || npart[5]
|| npart[4] || npart[3] || npart[2]) os+='pesos';
else if (npart[1]) os+=(npart[1]==1?'peso':'pesos');
else os+='cero pesos';
if (npart[0]) { os+=' con ';
if (npart[0]<smallnums.length) os+=smallnums[npart[0]];
else os+=(tens[Math.round((npart[0]-(npart[0]%10))/10)]
+ones[npart[0]%10]);
os+=(npart[0]==1?'centavo':'centavos'); }
return os; }
[/QUOTE]
ok..
im impressed!!!!
this is a serious code....
but im going to ask the las question!!!
i show the number in a field.....this field makes a query...(some vbscript
is involved) and shows some quantity... and then in other field..
i have to show this same quantity in letters..!
now the question.. how do i.. show this!!???
Thanks again and many regards for all
that read this!!!
Rt.[/QUOTE]
if(hto<20){
d+=ff[hto-1];
return (d+tt[num]);
}
if(hto<20){
[color=red]if(hto==0)
return(d);[/color]
d+=ff[hto-1];
return (d+tt[num]);
}
*SIGH*
No comments. Short obscure naming convention used for variables. Inconsistant indentation levels used for loops and if statements. Use of "magic numbers" sprinkled throughout the code, etc., etc..
In other words all that I have learned to expect from todays crop of programmers. ?
P.S. Sorry - did not actually look to see if the code worked, BUT don't Europeans use a decimal point instead of a comma to seperate their numbers every three digits? I seem to remember seeing that used somewhere.[/QUOTE]
0.1.9 — BETA 5.5