Bom dia
Fiz esta rotina faz muito tempo, veja se serve
funct ajustaHis(xhistorico,xlargura)
// justifica a direita
local contlin,texto,falta:=0 , vhistorico:="" ,a
xhistorico:=strtran( xhistorico,chr(13)+chr(10) ,"" )
contlin=mlcount(xhistorico,xlargura)
if contlin=0
retu .t.
endif
for a=1 to contlin
texto:=trim(memoline(xhistorico,xlargura,a))
IF .NOT. EMPTY(TEXTO)
margemE:=len(texto)-len(ltrim(texto))
falta:=xlargura-len(texto)
// verifica a quantidade de ocorrencias dessa linha
if right(texto,1)#"." .and. falta>0
texto:=strtran(alltrim(texto)," "," ","",falta)
CONTA:=0
do while margeME+len(texto)<xlargura .AND. CONTA<XLARGURA
texto:=strtran(alltrim(texto)," "," ",1,1)
CONTA++
enddo
vhistorico+=space(MargemE)+texto+fl
else
vhistorico+=texto+fl
endif
ELSE
vhistorico+=texto+fl
ENDIF
next
retu vhistorico
Poka