Hola otra vez Caro.
He estado probando el último código pero hay algo que no marcha.No localizo donde está el fallo.
Cuando me dá la respuesta, me aparece la respuesta+elEdit1+la última palabra.
Frase ejemplo:
estoy mal respuesta: cuanto hace que estas estoymalmal.
Código Delphi
[-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
sl : TStringList;
Cadena, respuesta, pregunta : String;
i : Integer;
Indice : Integer;
begin
If Key <> #13 then Exit;
Table1.Open;
Table2.Open;
sl := TStringList.Create;
sl.Delimiter := #32;
sl.DelimitedText := Edit1.Text;
sl.Insert(1,Edit1.Text);
try
Memo1.Lines.Add(Edit1.Text);
Indice := -1;
for i := 0 to sl.Count-1 do
begin
If (Table1.Locate('PALABRA', sl[i],[loCaseInsensitive]))then
begin
Indice := i;
break;
end;
end;
if Indice>=0 then
begin
if (Table2.Locate('NUMERO',Table1.fieldByName('NUMERO').AsString, [loCaseInsensitive])) then
begin
sl.Delete(Indice);
if Indice<>0 then
sl.Delete(0);
respuesta := Table2.fieldByName('RESPUESTA').AsString;
Cadena := '';
for i:=0 to sl.Count-1 do
Cadena := Cadena+sl[i];
respuesta :=StringReplace(respuesta ,'*',Cadena,[rfReplaceAll,rfIgnoreCase]);
Memo1.Lines.Add(respuesta);
end;
Table1.Close;
Table2.Close;
Edit1.Text := '';
end;
finally
end;
end;
end.
Saludos