Hola NeoNew.
Cuando agregaste "Cuento con una tabla de convenciones...", me quedé pensando que quizá sea muy larga la lista de abreviaturas y del modo anterior te resultaría un poco tedioso...
Si ya tenes una tabla creada, podrías hacer:
Código Delphi
[-]
...
implementation
var
FPalabra: TStrings;
FAbrev: TStrings;
procedure TForm1.FormCreate(Sender: TObject);
begin
FPalabra:= TStringList.Create;
FAbrev:= TStringList.Create;
with tbAbreviaturas do
begin
Open;
while not eof do
begin
FPalabra.Add(FieldByName('Palabra').AsString);
FAbrev.Add(FieldByName('Abreviat').AsString);
Next;
end;
Close;
end;
end;
function TForm1.Abreviar(const Texto: string): string;
var
i,ix: Integer;
begin
Result:= Texto;
with TStringList.Create do
try
Delimiter:= ' ';
DelimitedText:= Texto;
for i:= 0 to Count-1 do
begin
ix:= FPalabra.IndexOf(Strings[i]);
if ix <>-1 then
Result:= StringReplace(Result, Strings[i],FAbrev[ix],[]);
end;
finally
Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label2.Caption:= Abreviar(Label1.Caption)
end;
...
procedure TForm1.FormDestroy(Sender: TObject);
begin
if Assigned(FPalabra) then
FPalabra.Free;
if Assigned(FAbrev) then
FAbrev.Free;
end;
Saludos.