Pascal/Turbo Pascal - TRADUCIR CODIGO

 
Vista:

TRADUCIR CODIGO

Publicado por Mjuiz (9 intervenciones) el 09/01/2005 23:05:55
Hola. A ver si alguien me pudiera ayudar: tengo el siguiente código en JAVASCRIPT y quiero tradurcirlo a PASCAL. No se si es posible, pero me ayudaría mucho. ¿Existe alguna aplicación para ello?. Si no pudiese ser, también me ayudaría que me orientaseis sobre cómo hacerlo en PASCAL

<script language = "JavaScript">

function process1 (count) { // for words
m=new Array(10000);
m1=new Array(10000);
N=new Array (10000);
for (i=0;i<=1;i++) // which is chosen
{ if ( count.radio1[i].checked)
{ ch=i;
}
}

A=count.message.value; // original message
B="";
A=" " + A+" ";
A=A.toUpperCase(); // changes all alphas to Upper case
if (ch==0) // get rid of everything but apha's
{ condense1(count);
}
else
{ lesscondense(count);
}
for (i=1;i<=A.length;i++) // trims leading spaces and multiple spaces
{ if ((!(A.charAt(i)==" ")) || (!(A.charAt(i-1)==" ")))
{B=B + A.charAt(i);
}
}
//count.result1.value=B;
B=B+" "; // makes sure there is a space at end

k=0; str=" ";

for (i=0;i<=B.length;i++)
{ k1=B.indexOf(str,k);
if (k1==-1) //end of string B
{ Numwords=i-1;
break;
}
m[i+1]=B.substring(k,k1); // places all the words into an array m
k=k1+1;
}
//count.result1.value=B;
C="";
NN=0;
for (i=1;i<=Numwords; i++) // Numwords is total number of words
{ if (!(m[i]=="")) // only looks at m1 words that have not been processed before (not empty)
{ NN=NN+1; //unique word stored in m1 array
m1[NN]=m[i];
N[NN]=1; // initialize counter for word
for (j=i+1;j<=Numwords+1;j++) //counts and makes m1 elements with unique word empty.
{ if (m1[NN]==m[j])
{ N[NN]=N[NN]+1;
m[j]="";
}
}
}
}
C=C+"Unique:" + NN+" Total:" + Numwords+"\n";
C=C+"Freq.\tWord\n";
for (i=1;i<=NN;i++) // sets up C for showing
{ C=C + N[i]+ "\t" + m1[i] + "\n";
}
count.result1.value=C;
}

function condense1(count) { // allows only alpha's and spaces for choice 1
C="";
for (i=0;i<=A.length-1;i++)
{ k=A.charCodeAt(i);
if (((k>64) && (k<91)) || (k==32))
{ C=C+A.charAt(i);
}
else
{ C=C+" ";
}
}
A=C;
//count.result1.value=B;
}
function lesscondense(count) { // allows all characters from space on
C="";
for (i=0;i<=A.length-1;i++)
{ k=A.charCodeAt(i);
if (k>31)
{ C=C+A.charAt(i);
}
else
{ C=C+" ";
}
}
A=C;
}
//========================================
function letters1(count) { // counting characters upto unicode #255
mN=new Array(5000);
for (i=0;i<=1;i++) // which is chosen
{ if ( count.radio2[i].checked)
{ ch1=i;
}
}
A=count.message.value;
T=0;
for (i=0;i<=5000;i++) // initialize Array mN to 0
{ mN[i]=0;
}

for (i=0;i<=A.length-1;i++) // k is character and counted in mN[k]
{ k=A.charCodeAt(i);
mN[k]=mN[k]+1;
}
//count.result1.value=E;
D="";
D=D+"Freq.\tLetter\n"
if (ch1==0) // shows only alpha's and total number of letters T
{ for (i=65; i<91;i++)
{ if (!(mN[i]==0))
{ D=D + mN[i] + "\t"+ String.fromCharCode(i) + "\n";
T=T+mN[i];
}
}
for (i=97;i<=122;i++)
{ if (!(mN[i]==0))
{ D=D+mN[i]+"\t"+String.fromCharCode(i)+"\n";
T=T+mN[i];
}
}
}
else // shows all characters from space (32) to unicode 255
{ for (i=32; i<=255;i++)
{ if (!(mN[i]==0))
{ D=D + mN[i] + "\t"+ String.fromCharCode(i) + "\n";
T=T+mN[i];
}
}
}
count.result1.value=D;
count.total.value=T;
count.wordav.value=Math.round(T/Numwords*10000)/10000; // rounds off
}

function sortfreq(count) { // sorts words according to frequency
for (i=1;i<=NN-1;i++)
{ for (j=i+1;j<=NN;j++)
{ if (N[i]<N[j])
{ temp=m1[i];
m1[i]=m1[j];
m1[j]=temp;
temp=N[i];
N[i]=N[j];
N[j]=temp;
}
}
}
C="Unique words:" + NN+" Total words:" + Numwords+"\n";
C=C+"Freq.\tWord\n";
for (i=1;i<=NN;i++)
{ C=C + N[i]+ "\t" + m1[i] + "\n";
}
count.result1.value=C;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:TRADUCIR CODIGO

Publicado por Ivanchuk (1 intervención) el 12/01/2005 23:06:00
tu e-mail?? asi te paso el codigo. saludosssssssss
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar