Saludos mis amigos, este es un problema recurrente que tengo haec tiempo y quizas de muchos de ustedes, propongo solucionarlo de una vez por todas, estuve investigando y encontre esta funcion, sin embargo, al parecer tiene un error:
Código Delphi
[-]function Justifica(mCad:string;mMAx:integer):string;
var
mPos,mPont,mTam,mNr,mCont :integer;
mStr : string;
begin
mTam:=Length(mCad);
if mTam>=mMax then
Result:=copy(mCad,1,mMax)
else
begin
mStr:='''';
mCont:=0;
mPont:=1;
mNr:=mMax-mTam;
end;
while mCont mPos
mPos:=pos(mStr,copy(mCad,mPont,100));
if mPos=0 then
begin
mStr:=mStr+' ';
mPont:=1;
continue;
end
else
begin
mCont:=mCont+1;
Insert(' ',mCad,mPos+mPont);
mPont:=mPont+mPos+length(mStr);
end;
Result:=mCad;
end;
Si alguien tiene una funcion que haga el trabajo, por favor comparta el codigo aqui.
Muchos saludos