Pascal/Turbo Pascal - ayuda con diccionario en pascal

 
Vista:

ayuda con diccionario en pascal

Publicado por sotma (3 intervenciones) el 12/07/2011 11:13:53
hola , necesito ayuda para crear un diccionario de frases español-ingles en pascal con palabras definidas dentro del mismo pseudocodigo, soy novato, y la verdad no se cm iniciar, cualquier ayuda o comentario es bien recibido muchas gracias
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

ayuda con diccionario en pascal

Publicado por ramon (2158 intervenciones) el 14/07/2011 19:34:03
{Espero te sirva de ayuda esto tienes para crear archivo de datos y como record prueba y me comentas y era eso}

program esping;
uses
crt;
type
datosreg = record
frase : array[1..2] of string;
end;
const
ing_esp : array[1..9] of string = (
'UNO*ONE','DOS*TWO','TRES*THREE','CUATRO*FOUR','CINCO*FIVE','SEIS*SIX',
'SIETE*SEVEN','OCHO*ELGHT','SI*YES');


var
f : file of datosreg;
dat : datosreg;
tecla : char;
x, y, i : integer;

function entrada(x1, y1 : integer) : string;
var
te : char;
co : integer;
dd : string[100];
begin
co := 1;
fillchar(dd,101,' ');
dd[0] := chr(100);
repeat
te := readkey;
if upcase(te) in[#65..#90,#165] then
begin
dd[co] := upcase(te);
dd[0] := chr(co);
gotoxy((x1 - 1) + co,y1);write(dd[co]);
co := co + 1;
if co > 100 then
co := 100;
end;
if te = #8 then
begin
co := co - 1;
if co < 1 then
co := 1;
dd[co] := ' ';
dd[0] := chr(co);
gotoxy((x1 - 1) + co,y1);write(dd[co]);
end;
until (te = #13) or (te = #27);
if te = #13 then
begin
entrada := copy(dd,1,length(dd));
end
else
begin
entrada := ' ';
end;
end;


procedure dicionario;
var
dato : string[100];
ki, cd : integer;
tec : char;
final : boolean;
begin
fillchar(dato,101,' ');
dato[0] := chr(100);
ki := 1;
cd := 1;
final := false;
x := 3;
y := 6;
gotoxy(x,y - 4);write('ENTRE DATOS DICCIONARIO ING/ESP=ESP/ING');
gotoxy(x,y - 2);write('Espa¤ol',' ','Ingles');
gotoxy(x,y);
repeat
tec := readkey;
if tec in[#65..#90,#165,#97..#122,#164] then
begin
if ki = 1 then
begin
dato[cd] := upcase(tec);
dato[0] := chr(cd);
gotoxy(x + cd,y);write(dato[cd]);
cd := cd + 1;
if cd > 100 then
cd := 100;
end;
if ki = 2 then
begin
dato[cd] := upcase(tec);
dato[0] := chr(cd);
gotoxy((x + 15) + cd,y);write(dato[cd]);
cd := cd + 1;
if cd > 100 then
cd := 100;
end;
if tec = #13 then
begin
case ki of
1 : begin
dat.frase[1] := copy(dato,1,length(dato));
cd := 1;
ki := ki + 1;
fillchar(dato,101,' ');
dato[0] := chr(100);
gotoxy(x + 15,y);
end;
2 : begin
dat.frase[2] := copy(dato,1,length(dato));
final := true;
end;
end;
end;
end;
if tec = #8 then
begin
cd := cd - 1;
if cd < 1 then
cd := 1;
dato[cd] := ' ';
dato[0] := chr(cd);
if ki = 1 then
begin
gotoxy(x + cd,y);write(dato[cd]);
end;
if ki = 2 then
begin
gotoxy((x + 15) + cd,y);write(dato[cd]);
end;
end;
until (final = true) or (tec = #27);
if final = true then
begin
assign(f,'DiEspIng.dat');
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
rewrite(f);
seek(f,0);
write(f,dat);
close(f);
end
else
begin
seek(f,filesize(f));
write(f,dat);
close(f);
end;
end;
end;

procedure presenta_esp_ing(cuales : char);
var
fras : string;
cont : longint;
locali,encot : boolean;
paso : integer;
da1, da2 : string;
begin
encot := false;
gotoxy(4,6);write('Entre Palabra En ESP : ');
gotoxy(26,6);
fras := entrada(26,6);
gotoxy(26,4);write('ESP');
if cuales in['a','A'] then
begin
assign(f,'DiEspIng.dat');
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
exit;
end
else
begin
cont := 0;
repeat
seek(f,cont);
read(f,dat);
if dat.frase[1] = (fras + #13) then
begin
gotoxy((26 + length(fras)) + 4,4);write('ING');
gotoxy((26 + length(fras)) + 4,6);write(dat.frase[2]);
encot := true;
end;
cont := cont + 1;
until (encot = true) or (cont > filesize(f) - 1);
close(f);
end;
end;
if cuales in['r','R'] then
begin
cont := 1;
encot := false;
repeat
paso := 1;
locali := false;
repeat
if ing_esp[cont][paso] = '*' then
begin
locali := true;
end;
paso := paso + 1;
until locali = true;
da1 := copy(ing_esp[cont],1,paso - 2);
if da1 = fras then
begin
paso := 1;
locali := false;
repeat
if ing_esp[cont][paso] = '*' then
locali := true;
paso := paso + 1;
until (locali = true) or (paso > length(ing_esp[cont]));
da2 := copy(ing_esp[cont],paso,length(ing_esp[cont]));
gotoxy((26 + length(fras)) + 4,4);write('ING');
gotoxy((26 + length(fras)) + 4,6);write(da2);
encot := true;
end;
cont := cont + 1;
until (encot = true) or (cont > 9);
end;
if encot = true then
begin
writeln;
writeln;
writeln(' *** Pulse una Tecla ***');
repeat until keypressed;
end;
end;

procedure presenta_ing_esp(cuales : char);
var
fras : string;
cont : longint;
locali, encot : boolean;
paso : integer;
da1, da2 : string;
begin
gotoxy(4,6);write('Entre Palabra En ING : ');
gotoxy(26,6);
fras := entrada(26,6);
gotoxy(26,4);write('ING');
if cuales in['a','A'] then
begin
assign(f,'DiEspIng.dat');
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
exit;
end
else
begin
cont := 0;
repeat
seek(f,cont);
read(f,dat);
if dat.frase[2] = (fras + #13) then
begin
gotoxy((26 + length(fras)) + 4,4);write('ESP');
gotoxy((26 + length(fras)) + 4,6);write(dat.frase[1]);
encot := true;
end;
cont := cont + 1;
until (encot = true) or (cont > filesize(f) - 1);
close(f);
end;
end;
if cuales in['r','R'] then
begin
cont := 1;
encot := false;
repeat
paso := 1;
locali := false;
repeat
if ing_esp[cont][paso] = '*' then
begin
locali := true;
end;
paso := paso + 1;
until locali = true;
da1 := copy(ing_esp[cont],paso,length(ing_esp[cont]));
if da1 = fras then
begin
paso := 1;
locali := false;
repeat
if ing_esp[cont][paso] = '*' then
locali := true;
paso := paso + 1;
until (locali = true) or (paso > length(ing_esp[cont]));
da2 := copy(ing_esp[cont],1,paso - 1);
gotoxy((26 + length(fras)) + 4,4);write('ESP');
gotoxy((26 + length(fras)) + 4,6);write(da2);
encot := true;
end;
cont := cont + 1;
until (encot = true) or (cont > 9);
end;
if encot = true then
begin
writeln;
writeln;
writeln(' *** Pulse una Tecla ***');
repeat until keypressed;
end;
end;

procedure mascara;
begin
clrscr;
gotoxy(2,2);write('MENU ELIJA OPCION [1/2/3/4]');
gotoxy(2,4);write(' 1 = ENTRADA DATOS A ARCHIVO');
gotoxy(2,6);write(' 2 = PRESENTA ING/ESP');
gotoxy(2,8);write(' 3 = PRESENTA ESP/ING');
gotoxy(2,10);write(' 4 = SALIR');
end;

procedure menu;
var
final : boolean;
cu, teca : char;
begin
mascara;
final := false;
repeat
teca := readkey;
case teca of
#49 : begin
clrscr;
dicionario;
mascara;
end;
#50 : begin
clrscr;
gotoxy(4,2);write('PRESENTA CON DISCO[A] O RECORD[R]');
repeat
cu := readkey;
until cu in['a','A','r','R'];
gotoxy(4,2);clreol;
presenta_ing_esp(cu);
mascara;
end;
#51 : begin
clrscr;
gotoxy(4,2);write('PRESENTA CON DISCO[A] O RECORD[R]');
repeat
cu := readkey;
until cu in['a','A','r','R'];
gotoxy(4,2);clreol;
presenta_esp_ing(cu);
mascara;
end;
#52 : begin
final := true;
end;
end;
until final = true;
clrscr;
end;


begin
clrscr;
textcolor(15);
menu;
end.
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

ayuda con diccionario en pascal

Publicado por sotma (3 intervenciones) el 16/07/2011 06:19:13
muchas gracias, el problema radica en lo siguiente, no me permiten usar muchas de las cosas q utilizaste, x ejemplo no puedo incluir arreglos, tendria q ser solamente utilizando las funciones copy , concat, y las palabras a traducir deben estar declaradas dentro del mismo psudocodigo, y luego que se puedan concatenar asi logrando la frase que desee armar el usuario! de nuevo, muchas gracias
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

ayuda con diccionario en pascal

Publicado por ramon (2158 intervenciones) el 16/07/2011 16:05:16
{Esto es mas simple a ver si te ayuda}

program esping;
uses
crt;

const
letras : string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

var
frase : string;
atrad : string;


function toma_frase(paesp : string) : string;
var
p, nn, erro, i : integer;
dat, conju, nume : string;

begin
gotoxy(1,1);write('La Palabra a Traducir Es [',paesp,']');
for i := 1 to 26 do
begin
gotoxy(1 + (i * 3),3);write(i);
gotoxy(1 + (i * 3),4);write(letras[i]);
end;
gotoxy(1,7);write('Entre Los N§ De Las Letras Que Componen Palabra',
' En Ingles Se Parados Por [/]');
gotoxy(1,8);readln(nume);
nume := nume + '/';
conju := ' ';
dat := ' ';
p := 1;
for i := 1 to length(nume) do
begin
if nume[i] <> '/' then
begin
conju[p] := nume[i];
conju[0] := chr(p);
p := p + 1;
end
else
begin
val(conju,nn,erro);
dat := dat + copy(letras,nn,1);
conju := ' ';
p := 1;
end;
end;
toma_frase := copy(dat,1,length(dat));
end;

begin
clrscr;
atrad := 'DOS'; {Frase ESP a traducir}
frase := toma_frase(atrad); {Frase ING Traducida}
clrscr;
writeln('ESP = ',atrad,' ','ING = ',frase);
readln;
end.
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

ayuda con diccionario en pascal

Publicado por sotma (3 intervenciones) el 17/07/2011 06:49:22
gracias lo voy a probar y te cuento!!!
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

ayuda con diccionario en pascal

Publicado por maotuk (3 intervenciones) el 06/08/2011 08:19:40
y no le sirvio???
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