Newsgrupos.com  

Retroceder   Newsgrupos.com > Forum > Newsgroup microsoft.public.es.* 2 Foro > Newsgroup microsoft.public.es.vfoxpro.informes
Registrarse Preguntas Frecuentes Lista de Foreros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos




Respuesta
 
LinkBack Herramientas Desplegado
  #1 (permalink)  
Antiguo 23-10-2005, 19:50:09
Armando Diaz
 
Mensajes: n/a
Predeterminado Informes

Hola, si alguien sabe como presentar un campo de texto justificado,
agradecere su ayuda gracias.

----------------------------------------------
PortalFox :: Nada corre como un zorr
http://www.portalfox.co

PortalFox - NNTP Forum Gatewa
-----------------------------------------------
Responder Con Cita
Alt Today
Advertising
Google Adsense
 
This advertising will not be shown
in this way to registered members.
Register your free account today
and become a member on
Newsgrupos.com
Standard Sponsored Links

  #2 (permalink)  
Antiguo 24-10-2005, 18:34:40
Gabriel Dameñov
 
Mensajes: n/a
Predeterminado Re: Informes

Estimado Armando:
Esto lo encontré en PortalFox:

Hace unas semanas tuve la necesidad de imprimir texto justificado en un
informe de VFP, el cual venia desde un campo memo, al no recibir una
solución, decidi hacerlo yo mismo y ya he terminado. Coloco aqui la clase
que realice y como la utilizo en mi aplicación.

Espero que le puedan dar uso y si es posible que la mejoraran.

Saludos...

Oscar Gonzalez Hernandez
Mexico D.F


Uso de la Clase:


LOCAL loJustify
loJustify = CREATEOBJECT("justify")
loJustify.cSalidaTexto = "salida.txt"
loJustify.set_textmerge_on
loJustify.dojustify(cTexto,nLong)
loJustify.set_textmerge_off

Donde:
cTexto = Texto que se quiere justificar
nLong = Longitud en caracteres a justificar
Despues Revisar el archivo salida.txt


**************************************************
*-- Class: justify
*-- ParentClass: custom
*-- BaseClass: custom
*-- Author: Oscar Gonzalez Hernandez
*
DEFINE CLASS justify AS CUSTOM
HEIGHT = 15
WIDTH = 16
*-- Contiene el texto ya justificado y se va acumulando
*-- hasta contener todo el texto justificado.
ctextoacumulado = ""
NAME = "justify"
*-- Contiene el nombre del archivo que se
*-- creará con el texto justificado.
csalidatexto = .F.
*-- Separa el texto pasado como parámetro en diferentes
*-- bloques si ses que se encuentran retornos de carro,
*-- sino regresa el texto completo.
PROCEDURE SEPARA
LPARAMETERS tcParrafo,taBloques,tbBloques
lnDimension = 0
FOR i = 1 TO LEN(tcParrafo)
IF ASC(SUBSTR(tcParrafo,i,1)) = 13
lnDimension = lnDimension + 1
DIMENSION laRetornos(lnDimension)
laRetornos(lnDimension) = i
ENDIF
ENDFOR
IF VARTYPE(laRetornos) = "U"
tbBloques = .F.
taBloques = tcParrafo
RETURN ***taBloques
ENDIF
lnInicio = 1
FOR k = 1 TO ALEN(laRetornos)
DIMENSION taBloques(k)
taBloques(k) = SUBSTR(tcParrafo,lnInicio,laRetornos(k)-lnInicio)
lnInicio = laRetornos(k)+1
ENDFOR
DIMENSION taBloques(k)
taBloques(k) = SUBSTR(tcParrafo,lnInicio,LEN(tcParrafo)+1-lnInicio)
tbBloques = .T.
RETURN ***taBloques
ENDPROC
*-- Ejecuta el proceso de justificado del texto separado
*-- en bloques o texto único regresado por el método separa().
PROCEDURE dojustify
LPARAMETERS tcTextoJustificar,tnLongJustificado
LOCAL lgBloques,lbBloques
THIS.SEPARA(tcTextoJustificar,***lgBloques,***lbBloque s)
IF lbBloques && Se ha partido el exto en bloques
FOR lnCont = 1 TO ALEN(lgBloques)
THIS.ctextoacumulado = ""
THIS.Justificar(lgBloques(lnCont),tnLongJustificad o)
TEXT
<<This.ctextoacumulado>>
ENDTEXT
ENDFOR
ELSE
THIS.ctextoacumulado = ""
THIS.Justificar(lgBloques,tnLongJustificado)
TEXT
<<This.ctextoacumulado>>
ENDTEXT
ENDIF
RETURN
ENDPROC
*-- Método recursivo que justifica párrafo por párrafo
*-- según la longitud de caracteres que se le indique.
PROCEDURE justificar
LPARAMETERS tcTexto,tnTamaño
IF EMPTY(SUBSTR(tcTexto,tnTamaño,1))
lcTextoJ = ALLTRIM(SUBSTR(tcTexto,1,tnTamaño-1))
IF EMPTY(lcTextoJ)
RETURN
ENDIF
tcTextoAlterno = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
IF !EMPTY(tcTextoAlterno)
lcTextoAcumular = THIS.rellena(lcTextoJ,tnTamaño)
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ELSE
lcTextoAcumular = lcTextoJ
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ENDIF
ELSE
lcChar = SUBSTR(tcTexto,tnTamaño,1)
lnContador = tnTamaño
DO WHILE !EMPTY(lcChar)
lnContador = lnContador - 1
lcChar = SUBSTR(tcTexto,lnContador,1)
ENDDO
lcTextoJ = ALLTRIM(SUBSTR(tcTexto,1,lnContador))
tcTextoAlterno = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
IF !EMPTY(tcTextoAlterno)
lcTextoAcumular = THIS.rellena(lcTextoJ,tnTamaño)
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,lnContador+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ELSE
lcTextoAcumular = lcTextoJ
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,lnContador+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ENDIF
ENDIF
ENDPROC
*-- Rellena el párrafo cortado por el método justificar()
*-- con el número de espacios correspondientes para crear
*-- un parrafo de la longitud deseada.
PROCEDURE rellena
LPARAMETERS tcParrafo,tnLong
IF LEN(tcParrafo) = tnLong
RETURN tcParrafo
ENDIF
lnDimension = 0
lcPalabra = ""
FOR i = 1 TO LEN(tcParrafo)
IF ASC(SUBSTR(tcParrafo,i,1)) = 32
lnDimension = lnDimension + 1
DIMENSION laEspacios(lnDimension)
laEspacios(lnDimension) = i
ENDIF
ENDFOR
IF VARTYPE(laEspacios) = "U"
RETURN tcParrafo
ENDIF
lnInicio = 1
FOR k = 1 TO ALEN(laEspacios)
DIMENSION laPalabras(k)
laPalabras(k) = SUBSTR(tcParrafo,lnInicio,laEspacios(k)-lnInicio)
lnInicio = laEspacios(k)+1
ENDFOR
DIMENSION laPalabras(k)
laPalabras(k) = SUBSTR(tcParrafo,lnInicio,LEN(tcParrafo)+1-lnInicio)
lnTotalEspacios = tnLong - LEN(tcParrafo)
lnEspaciosContados = 0
DO WHILE !EMPTY(lnTotalEspacios)
FOR l = 1 TO ALEN(laPalabras)-1
laPalabras(l) = laPalabras(l) + " "
lnTotalEspacios = lnTotalEspacios - 1
IF EMPTY(lnTotalEspacios)
EXIT
ENDIF
ENDFOR
ENDDO
lcParrafoFormateado = ""
lcParrafoFormateado = laPalabras(1)
FOR j = 2 TO ALEN(laPalabras)
lcParrafoFormateado = lcParrafoFormateado + " " + laPalabras(j)
ENDFOR
RETURN lcParrafoFormateado
ENDPROC
*-- Activa la configuración de salida del texto justificado.
PROCEDURE set_textmerge_on
SET TEXTMERGE TO (THIS.csalidatexto) NOSHOW
SET TEXTMERGE ON
ENDPROC
*-- Desactiva la configuración de salida del texto justificado.
PROCEDURE set_textmerge_off
SET TEXTMERGE TO
SET TEXTMERGE OFF
ENDPROC
ENDDEFINE




Responder Con Cita
  #3 (permalink)  
Antiguo 24-10-2005, 18:34:40
Gabriel Dameñov
 
Mensajes: n/a
Predeterminado Re: Informes

Estimado Armando:
Esto lo encontré en PortalFox:

Hace unas semanas tuve la necesidad de imprimir texto justificado en un
informe de VFP, el cual venia desde un campo memo, al no recibir una
solución, decidi hacerlo yo mismo y ya he terminado. Coloco aqui la clase
que realice y como la utilizo en mi aplicación.

Espero que le puedan dar uso y si es posible que la mejoraran.

Saludos...

Oscar Gonzalez Hernandez
Mexico D.F


Uso de la Clase:


LOCAL loJustify
loJustify = CREATEOBJECT("justify")
loJustify.cSalidaTexto = "salida.txt"
loJustify.set_textmerge_on
loJustify.dojustify(cTexto,nLong)
loJustify.set_textmerge_off

Donde:
cTexto = Texto que se quiere justificar
nLong = Longitud en caracteres a justificar
Despues Revisar el archivo salida.txt


**************************************************
*-- Class: justify
*-- ParentClass: custom
*-- BaseClass: custom
*-- Author: Oscar Gonzalez Hernandez
*
DEFINE CLASS justify AS CUSTOM
HEIGHT = 15
WIDTH = 16
*-- Contiene el texto ya justificado y se va acumulando
*-- hasta contener todo el texto justificado.
ctextoacumulado = ""
NAME = "justify"
*-- Contiene el nombre del archivo que se
*-- creará con el texto justificado.
csalidatexto = .F.
*-- Separa el texto pasado como parámetro en diferentes
*-- bloques si ses que se encuentran retornos de carro,
*-- sino regresa el texto completo.
PROCEDURE SEPARA
LPARAMETERS tcParrafo,taBloques,tbBloques
lnDimension = 0
FOR i = 1 TO LEN(tcParrafo)
IF ASC(SUBSTR(tcParrafo,i,1)) = 13
lnDimension = lnDimension + 1
DIMENSION laRetornos(lnDimension)
laRetornos(lnDimension) = i
ENDIF
ENDFOR
IF VARTYPE(laRetornos) = "U"
tbBloques = .F.
taBloques = tcParrafo
RETURN ***taBloques
ENDIF
lnInicio = 1
FOR k = 1 TO ALEN(laRetornos)
DIMENSION taBloques(k)
taBloques(k) = SUBSTR(tcParrafo,lnInicio,laRetornos(k)-lnInicio)
lnInicio = laRetornos(k)+1
ENDFOR
DIMENSION taBloques(k)
taBloques(k) = SUBSTR(tcParrafo,lnInicio,LEN(tcParrafo)+1-lnInicio)
tbBloques = .T.
RETURN ***taBloques
ENDPROC
*-- Ejecuta el proceso de justificado del texto separado
*-- en bloques o texto único regresado por el método separa().
PROCEDURE dojustify
LPARAMETERS tcTextoJustificar,tnLongJustificado
LOCAL lgBloques,lbBloques
THIS.SEPARA(tcTextoJustificar,***lgBloques,***lbBloque s)
IF lbBloques && Se ha partido el exto en bloques
FOR lnCont = 1 TO ALEN(lgBloques)
THIS.ctextoacumulado = ""
THIS.Justificar(lgBloques(lnCont),tnLongJustificad o)
TEXT
<<This.ctextoacumulado>>
ENDTEXT
ENDFOR
ELSE
THIS.ctextoacumulado = ""
THIS.Justificar(lgBloques,tnLongJustificado)
TEXT
<<This.ctextoacumulado>>
ENDTEXT
ENDIF
RETURN
ENDPROC
*-- Método recursivo que justifica párrafo por párrafo
*-- según la longitud de caracteres que se le indique.
PROCEDURE justificar
LPARAMETERS tcTexto,tnTamaño
IF EMPTY(SUBSTR(tcTexto,tnTamaño,1))
lcTextoJ = ALLTRIM(SUBSTR(tcTexto,1,tnTamaño-1))
IF EMPTY(lcTextoJ)
RETURN
ENDIF
tcTextoAlterno = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
IF !EMPTY(tcTextoAlterno)
lcTextoAcumular = THIS.rellena(lcTextoJ,tnTamaño)
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ELSE
lcTextoAcumular = lcTextoJ
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ENDIF
ELSE
lcChar = SUBSTR(tcTexto,tnTamaño,1)
lnContador = tnTamaño
DO WHILE !EMPTY(lcChar)
lnContador = lnContador - 1
lcChar = SUBSTR(tcTexto,lnContador,1)
ENDDO
lcTextoJ = ALLTRIM(SUBSTR(tcTexto,1,lnContador))
tcTextoAlterno = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
IF !EMPTY(tcTextoAlterno)
lcTextoAcumular = THIS.rellena(lcTextoJ,tnTamaño)
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,lnContador+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ELSE
lcTextoAcumular = lcTextoJ
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,lnContador+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ENDIF
ENDIF
ENDPROC
*-- Rellena el párrafo cortado por el método justificar()
*-- con el número de espacios correspondientes para crear
*-- un parrafo de la longitud deseada.
PROCEDURE rellena
LPARAMETERS tcParrafo,tnLong
IF LEN(tcParrafo) = tnLong
RETURN tcParrafo
ENDIF
lnDimension = 0
lcPalabra = ""
FOR i = 1 TO LEN(tcParrafo)
IF ASC(SUBSTR(tcParrafo,i,1)) = 32
lnDimension = lnDimension + 1
DIMENSION laEspacios(lnDimension)
laEspacios(lnDimension) = i
ENDIF
ENDFOR
IF VARTYPE(laEspacios) = "U"
RETURN tcParrafo
ENDIF
lnInicio = 1
FOR k = 1 TO ALEN(laEspacios)
DIMENSION laPalabras(k)
laPalabras(k) = SUBSTR(tcParrafo,lnInicio,laEspacios(k)-lnInicio)
lnInicio = laEspacios(k)+1
ENDFOR
DIMENSION laPalabras(k)
laPalabras(k) = SUBSTR(tcParrafo,lnInicio,LEN(tcParrafo)+1-lnInicio)
lnTotalEspacios = tnLong - LEN(tcParrafo)
lnEspaciosContados = 0
DO WHILE !EMPTY(lnTotalEspacios)
FOR l = 1 TO ALEN(laPalabras)-1
laPalabras(l) = laPalabras(l) + " "
lnTotalEspacios = lnTotalEspacios - 1
IF EMPTY(lnTotalEspacios)
EXIT
ENDIF
ENDFOR
ENDDO
lcParrafoFormateado = ""
lcParrafoFormateado = laPalabras(1)
FOR j = 2 TO ALEN(laPalabras)
lcParrafoFormateado = lcParrafoFormateado + " " + laPalabras(j)
ENDFOR
RETURN lcParrafoFormateado
ENDPROC
*-- Activa la configuración de salida del texto justificado.
PROCEDURE set_textmerge_on
SET TEXTMERGE TO (THIS.csalidatexto) NOSHOW
SET TEXTMERGE ON
ENDPROC
*-- Desactiva la configuración de salida del texto justificado.
PROCEDURE set_textmerge_off
SET TEXTMERGE TO
SET TEXTMERGE OFF
ENDPROC
ENDDEFINE




Responder Con Cita
  #4 (permalink)  
Antiguo 24-10-2005, 18:34:40
Gabriel Dameñov
 
Mensajes: n/a
Predeterminado Re: Informes

Estimado Armando:
Esto lo encontré en PortalFox:

Hace unas semanas tuve la necesidad de imprimir texto justificado en un
informe de VFP, el cual venia desde un campo memo, al no recibir una
solución, decidi hacerlo yo mismo y ya he terminado. Coloco aqui la clase
que realice y como la utilizo en mi aplicación.

Espero que le puedan dar uso y si es posible que la mejoraran.

Saludos...

Oscar Gonzalez Hernandez
Mexico D.F


Uso de la Clase:


LOCAL loJustify
loJustify = CREATEOBJECT("justify")
loJustify.cSalidaTexto = "salida.txt"
loJustify.set_textmerge_on
loJustify.dojustify(cTexto,nLong)
loJustify.set_textmerge_off

Donde:
cTexto = Texto que se quiere justificar
nLong = Longitud en caracteres a justificar
Despues Revisar el archivo salida.txt


**************************************************
*-- Class: justify
*-- ParentClass: custom
*-- BaseClass: custom
*-- Author: Oscar Gonzalez Hernandez
*
DEFINE CLASS justify AS CUSTOM
HEIGHT = 15
WIDTH = 16
*-- Contiene el texto ya justificado y se va acumulando
*-- hasta contener todo el texto justificado.
ctextoacumulado = ""
NAME = "justify"
*-- Contiene el nombre del archivo que se
*-- creará con el texto justificado.
csalidatexto = .F.
*-- Separa el texto pasado como parámetro en diferentes
*-- bloques si ses que se encuentran retornos de carro,
*-- sino regresa el texto completo.
PROCEDURE SEPARA
LPARAMETERS tcParrafo,taBloques,tbBloques
lnDimension = 0
FOR i = 1 TO LEN(tcParrafo)
IF ASC(SUBSTR(tcParrafo,i,1)) = 13
lnDimension = lnDimension + 1
DIMENSION laRetornos(lnDimension)
laRetornos(lnDimension) = i
ENDIF
ENDFOR
IF VARTYPE(laRetornos) = "U"
tbBloques = .F.
taBloques = tcParrafo
RETURN ***taBloques
ENDIF
lnInicio = 1
FOR k = 1 TO ALEN(laRetornos)
DIMENSION taBloques(k)
taBloques(k) = SUBSTR(tcParrafo,lnInicio,laRetornos(k)-lnInicio)
lnInicio = laRetornos(k)+1
ENDFOR
DIMENSION taBloques(k)
taBloques(k) = SUBSTR(tcParrafo,lnInicio,LEN(tcParrafo)+1-lnInicio)
tbBloques = .T.
RETURN ***taBloques
ENDPROC
*-- Ejecuta el proceso de justificado del texto separado
*-- en bloques o texto único regresado por el método separa().
PROCEDURE dojustify
LPARAMETERS tcTextoJustificar,tnLongJustificado
LOCAL lgBloques,lbBloques
THIS.SEPARA(tcTextoJustificar,***lgBloques,***lbBloque s)
IF lbBloques && Se ha partido el exto en bloques
FOR lnCont = 1 TO ALEN(lgBloques)
THIS.ctextoacumulado = ""
THIS.Justificar(lgBloques(lnCont),tnLongJustificad o)
TEXT
<<This.ctextoacumulado>>
ENDTEXT
ENDFOR
ELSE
THIS.ctextoacumulado = ""
THIS.Justificar(lgBloques,tnLongJustificado)
TEXT
<<This.ctextoacumulado>>
ENDTEXT
ENDIF
RETURN
ENDPROC
*-- Método recursivo que justifica párrafo por párrafo
*-- según la longitud de caracteres que se le indique.
PROCEDURE justificar
LPARAMETERS tcTexto,tnTamaño
IF EMPTY(SUBSTR(tcTexto,tnTamaño,1))
lcTextoJ = ALLTRIM(SUBSTR(tcTexto,1,tnTamaño-1))
IF EMPTY(lcTextoJ)
RETURN
ENDIF
tcTextoAlterno = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
IF !EMPTY(tcTextoAlterno)
lcTextoAcumular = THIS.rellena(lcTextoJ,tnTamaño)
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ELSE
lcTextoAcumular = lcTextoJ
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ENDIF
ELSE
lcChar = SUBSTR(tcTexto,tnTamaño,1)
lnContador = tnTamaño
DO WHILE !EMPTY(lcChar)
lnContador = lnContador - 1
lcChar = SUBSTR(tcTexto,lnContador,1)
ENDDO
lcTextoJ = ALLTRIM(SUBSTR(tcTexto,1,lnContador))
tcTextoAlterno = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
IF !EMPTY(tcTextoAlterno)
lcTextoAcumular = THIS.rellena(lcTextoJ,tnTamaño)
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,lnContador+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ELSE
lcTextoAcumular = lcTextoJ
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,lnContador+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ENDIF
ENDIF
ENDPROC
*-- Rellena el párrafo cortado por el método justificar()
*-- con el número de espacios correspondientes para crear
*-- un parrafo de la longitud deseada.
PROCEDURE rellena
LPARAMETERS tcParrafo,tnLong
IF LEN(tcParrafo) = tnLong
RETURN tcParrafo
ENDIF
lnDimension = 0
lcPalabra = ""
FOR i = 1 TO LEN(tcParrafo)
IF ASC(SUBSTR(tcParrafo,i,1)) = 32
lnDimension = lnDimension + 1
DIMENSION laEspacios(lnDimension)
laEspacios(lnDimension) = i
ENDIF
ENDFOR
IF VARTYPE(laEspacios) = "U"
RETURN tcParrafo
ENDIF
lnInicio = 1
FOR k = 1 TO ALEN(laEspacios)
DIMENSION laPalabras(k)
laPalabras(k) = SUBSTR(tcParrafo,lnInicio,laEspacios(k)-lnInicio)
lnInicio = laEspacios(k)+1
ENDFOR
DIMENSION laPalabras(k)
laPalabras(k) = SUBSTR(tcParrafo,lnInicio,LEN(tcParrafo)+1-lnInicio)
lnTotalEspacios = tnLong - LEN(tcParrafo)
lnEspaciosContados = 0
DO WHILE !EMPTY(lnTotalEspacios)
FOR l = 1 TO ALEN(laPalabras)-1
laPalabras(l) = laPalabras(l) + " "
lnTotalEspacios = lnTotalEspacios - 1
IF EMPTY(lnTotalEspacios)
EXIT
ENDIF
ENDFOR
ENDDO
lcParrafoFormateado = ""
lcParrafoFormateado = laPalabras(1)
FOR j = 2 TO ALEN(laPalabras)
lcParrafoFormateado = lcParrafoFormateado + " " + laPalabras(j)
ENDFOR
RETURN lcParrafoFormateado
ENDPROC
*-- Activa la configuración de salida del texto justificado.
PROCEDURE set_textmerge_on
SET TEXTMERGE TO (THIS.csalidatexto) NOSHOW
SET TEXTMERGE ON
ENDPROC
*-- Desactiva la configuración de salida del texto justificado.
PROCEDURE set_textmerge_off
SET TEXTMERGE TO
SET TEXTMERGE OFF
ENDPROC
ENDDEFINE




Responder Con Cita
  #5 (permalink)  
Antiguo 24-10-2005, 18:34:40
Gabriel Dameñov
 
Mensajes: n/a
Predeterminado Re: Informes

Estimado Armando:
Esto lo encontré en PortalFox:

Hace unas semanas tuve la necesidad de imprimir texto justificado en un
informe de VFP, el cual venia desde un campo memo, al no recibir una
solución, decidi hacerlo yo mismo y ya he terminado. Coloco aqui la clase
que realice y como la utilizo en mi aplicación.

Espero que le puedan dar uso y si es posible que la mejoraran.

Saludos...

Oscar Gonzalez Hernandez
Mexico D.F


Uso de la Clase:


LOCAL loJustify
loJustify = CREATEOBJECT("justify")
loJustify.cSalidaTexto = "salida.txt"
loJustify.set_textmerge_on
loJustify.dojustify(cTexto,nLong)
loJustify.set_textmerge_off

Donde:
cTexto = Texto que se quiere justificar
nLong = Longitud en caracteres a justificar
Despues Revisar el archivo salida.txt


**************************************************
*-- Class: justify
*-- ParentClass: custom
*-- BaseClass: custom
*-- Author: Oscar Gonzalez Hernandez
*
DEFINE CLASS justify AS CUSTOM
HEIGHT = 15
WIDTH = 16
*-- Contiene el texto ya justificado y se va acumulando
*-- hasta contener todo el texto justificado.
ctextoacumulado = ""
NAME = "justify"
*-- Contiene el nombre del archivo que se
*-- creará con el texto justificado.
csalidatexto = .F.
*-- Separa el texto pasado como parámetro en diferentes
*-- bloques si ses que se encuentran retornos de carro,
*-- sino regresa el texto completo.
PROCEDURE SEPARA
LPARAMETERS tcParrafo,taBloques,tbBloques
lnDimension = 0
FOR i = 1 TO LEN(tcParrafo)
IF ASC(SUBSTR(tcParrafo,i,1)) = 13
lnDimension = lnDimension + 1
DIMENSION laRetornos(lnDimension)
laRetornos(lnDimension) = i
ENDIF
ENDFOR
IF VARTYPE(laRetornos) = "U"
tbBloques = .F.
taBloques = tcParrafo
RETURN ***taBloques
ENDIF
lnInicio = 1
FOR k = 1 TO ALEN(laRetornos)
DIMENSION taBloques(k)
taBloques(k) = SUBSTR(tcParrafo,lnInicio,laRetornos(k)-lnInicio)
lnInicio = laRetornos(k)+1
ENDFOR
DIMENSION taBloques(k)
taBloques(k) = SUBSTR(tcParrafo,lnInicio,LEN(tcParrafo)+1-lnInicio)
tbBloques = .T.
RETURN ***taBloques
ENDPROC
*-- Ejecuta el proceso de justificado del texto separado
*-- en bloques o texto único regresado por el método separa().
PROCEDURE dojustify
LPARAMETERS tcTextoJustificar,tnLongJustificado
LOCAL lgBloques,lbBloques
THIS.SEPARA(tcTextoJustificar,***lgBloques,***lbBloque s)
IF lbBloques && Se ha partido el exto en bloques
FOR lnCont = 1 TO ALEN(lgBloques)
THIS.ctextoacumulado = ""
THIS.Justificar(lgBloques(lnCont),tnLongJustificad o)
TEXT
<<This.ctextoacumulado>>
ENDTEXT
ENDFOR
ELSE
THIS.ctextoacumulado = ""
THIS.Justificar(lgBloques,tnLongJustificado)
TEXT
<<This.ctextoacumulado>>
ENDTEXT
ENDIF
RETURN
ENDPROC
*-- Método recursivo que justifica párrafo por párrafo
*-- según la longitud de caracteres que se le indique.
PROCEDURE justificar
LPARAMETERS tcTexto,tnTamaño
IF EMPTY(SUBSTR(tcTexto,tnTamaño,1))
lcTextoJ = ALLTRIM(SUBSTR(tcTexto,1,tnTamaño-1))
IF EMPTY(lcTextoJ)
RETURN
ENDIF
tcTextoAlterno = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
IF !EMPTY(tcTextoAlterno)
lcTextoAcumular = THIS.rellena(lcTextoJ,tnTamaño)
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ELSE
lcTextoAcumular = lcTextoJ
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ENDIF
ELSE
lcChar = SUBSTR(tcTexto,tnTamaño,1)
lnContador = tnTamaño
DO WHILE !EMPTY(lcChar)
lnContador = lnContador - 1
lcChar = SUBSTR(tcTexto,lnContador,1)
ENDDO
lcTextoJ = ALLTRIM(SUBSTR(tcTexto,1,lnContador))
tcTextoAlterno = SUBSTR(tcTexto,tnTamaño+1,LEN(tcTexto))
IF !EMPTY(tcTextoAlterno)
lcTextoAcumular = THIS.rellena(lcTextoJ,tnTamaño)
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,lnContador+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ELSE
lcTextoAcumular = lcTextoJ
THIS.ctextoacumulado = THIS.ctextoacumulado + lcTextoAcumular +
CHR(13)
tcTexto = SUBSTR(tcTexto,lnContador+1,LEN(tcTexto))
THIS.justificar(tcTexto,tnTamaño)
ENDIF
ENDIF
ENDPROC
*-- Rellena el párrafo cortado por el método justificar()
*-- con el número de espacios correspondientes para crear
*-- un parrafo de la longitud deseada.
PROCEDURE rellena
LPARAMETERS tcParrafo,tnLong
IF LEN(tcParrafo) = tnLong
RETURN tcParrafo
ENDIF
lnDimension = 0
lcPalabra = ""
FOR i = 1 TO LEN(tcParrafo)
IF ASC(SUBSTR(tcParrafo,i,1)) = 32
lnDimension = lnDimension + 1
DIMENSION laEspacios(lnDimension)
laEspacios(lnDimension) = i
ENDIF
ENDFOR
IF VARTYPE(laEspacios) = "U"
RETURN tcParrafo
ENDIF
lnInicio = 1
FOR k = 1 TO ALEN(laEspacios)
DIMENSION laPalabras(k)
laPalabras(k) = SUBSTR(tcParrafo,lnInicio,laEspacios(k)-lnInicio)
lnInicio = laEspacios(k)+1
ENDFOR
DIMENSION laPalabras(k)
laPalabras(k) = SUBSTR(tcParrafo,lnInicio,LEN(tcParrafo)+1-lnInicio)
lnTotalEspacios = tnLong - LEN(tcParrafo)
lnEspaciosContados = 0
DO WHILE !EMPTY(lnTotalEspacios)
FOR l = 1 TO ALEN(laPalabras)-1
laPalabras(l) = laPalabras(l) + " "
lnTotalEspacios = lnTotalEspacios - 1
IF EMPTY(lnTotalEspacios)
EXIT
ENDIF
ENDFOR
ENDDO
lcParrafoFormateado = ""
lcParrafoFormateado = laPalabras(1)
FOR j = 2 TO ALEN(laPalabras)
lcParrafoFormateado = lcParrafoFormateado + " " + laPalabras(j)
ENDFOR
RETURN lcParrafoFormateado
ENDPROC
*-- Activa la configuración de salida del texto justificado.
PROCEDURE set_textmerge_on
SET TEXTMERGE TO (THIS.csalidatexto) NOSHOW
SET TEXTMERGE ON
ENDPROC
*-- Desactiva la configuración de salida del texto justificado.
PROCEDURE set_textmerge_off
SET TEXTMERGE TO
SET TEXTMERGE OFF
ENDPROC
ENDDEFINE




Responder Con Cita
 
Respuesta


Herramientas
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Trackbacks are habilitado
Pingbacks are habilitado
Refbacks are habilitado


Temas Similares
Tema Autor Foro Respuestas Último mensaje
Necesito hacer informes con hyperlink a otros informes e incluso a formulario Berman Cabrera Newsgroup microsoft.public.es.vfoxpro.informes 6 28-01-2007 03:12:15
Informes Victor Tomey Newsgroup microsoft.public.es.project 0 06-09-2006 10:07:20
Informes Analia Belmonte Newsgroup microsoft.public.es.vfoxpro.informes 0 21-07-2006 19:11:22
Informes Mavy Newsgroup microsoft.public.es.money 0 12-12-2003 22:27:14
Informes x FTP Angel Luis Newsgroup es.comp.bd.ms-access 0 07-11-2003 16:32:01





Powered by: vBulletin, Versión 3.6.8
Derechos de Autor ©2000 - 2008, Jelsoft Enterprises Ltd.

LinkBacks Enabled by vBSEO 3.1.0 © 2007, Crawlability, Inc.