ayuda con diccionario en pascal
{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.