FoxPress – Marzo 2001

 

Cómo justificar un campo Memo

http://www.fpress.com/

 

Por Ricardo Natella (FoxBoard)                                       * memo.prg



 

*******************************************

* Función: Imp_Just - Justifica la linea que se pasa como parámetro

* Parámetros: Tira = Renglón a justificar

*             CPL = Caracteres por Linea (Longitud de la linea)

*

* Ej. para Justificar un campo Memo

*

* SET MEMOWIDTH TO 80

* ..

* mMemoAux = ''

* FOR nNúmeroLínea=1 TO MEMLINES(CampoMemo)

* mMemoAux = mMemoaux + IMP_JUST( MLINE(CampoMemo, nNúmeroLínea), 80 )

* NEXT

* CampoMemo = mMemoAux

*

*******************************************

FUNCTION IMP_JUST( TIRA, CPL )

 

renglon_e = tira

IF SPACE(0) = ALLTRIM( renglon_e )

   return renglon_e

ENDIF

 

******** SACO TODOS LOS CARACTERES ASCII

******** 26, 13 - ENTER

CTA = occurs(chr(13),renglon_e)

for j = 1 to CTA

    renglon_x = left(renglon_e,at(;

  chr(13),renglon_e,1)-1)+;

       right(renglon_e,;

       len(renglon_e)-at(chr(13),;

  renglon_e,1))

    renglon_e = renglon_x  

endfor 

********************* SE SACAN LOS ****

********************* CARACTERES 26

CTA = occurs(chr(26),renglon_e)

for j = 1 to CTA

  renglon_x = left(renglon_e,at(;

        chr(26),renglon_e,1)-1)+;

         right(renglon_e,;

   len(renglon_e)-at(chr(26),;

    renglon_e,1))

  renglon_e = renglon_x  

endfor 

********************** SE JUSTIFICA LA

*****LINEA***************************

renglon_e = alltrim(renglon_e)

BLANCOS = CPL - len(renglon_e)

TIRA1 = ' '

TIRA2 = '  '

if BLANCOS <= round(CPL/3,0)               

** SE SUPONE QUE HAY MAS DE UNA PALABRA

   do while BLANCOS <> 0

  renglon_e = strtran(renglon_e,;

        TIRA1,TIRA2,1,BLANCOS)

 renglon_e = substr(renglon_e,1,CPL)

  BLANCOS = CPL - len(trim(renglon_e))

  TIRA1 = TIRA1 + ' '

  TIRA2 = TIRA2 + ' '

enddo

else

renglon_e = renglon_e + repl('-',BLANCOS)

endif

 

return renglon_e



 

 

FoxPress – Marzo de 2001

© 2001 FoxPress. All rights reserved