FoxPro/Visual FoxPro - IMPRIMIR UN NOMBRE LARGO EN 2 LINEAS

 
Vista:

IMPRIMIR UN NOMBRE LARGO EN 2 LINEAS

Publicado por MALLEN (1 intervención) el 26/09/2013 19:27:44
hola, lo que imprimo son boletas de calificaciones, pero resulta que el nombre de la unidad es muy largo y es necesario que se imrpima en dos reglones como hago para dar la intrucción si estoy utilizando el PROW (), gracias!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 1.011
Oro
Ha mantenido su posición en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

IMPRIMIR UN NOMBRE LARGO EN 2 LINEAS

Publicado por Fidel (558 intervenciones) el 26/09/2013 20:15:56
Supongo que cuando dices Prow(), te refieres a imprimir con ? / ??, ó @ prow(),ncol say.
Para el tema en particular escribí el procedure que copio a continuación:
Ejemplo:
lcFrase="Programa General de Calificaciones para Escuelas Secundarias de la Nación"
lnWid=30 && espacio en caracteres
dimension gamat(1)
nSepar = Separtext(lcFrase,lnWid,@gamat) && la matriz debe pasarse por referencia
&& nSepar=3 para el ejemplo
for i=1 to nSepar
if !empty(gamat[i])
if conArroba
@ prow()+1,1 say gamat[i]
else
? gamat[i] At 1 font "Arial",9
endif
endif
next

Seguramente se puede optimizar Separtext(), aunque de lo que tengo visto, funciona.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
PROCEDURE SEPARTEXT(cFrase,nAncho,xaMatriz,xnMinDef)
*-------------------------------------------------------------------------------------
local fi,qi,nit,lenfra,apunto,di,gaparte,ngap,xi,nis,;
       nspacios,nSaltos,sbFrase,xi_,nSepar
*
* xnMinDef se utiliza cuando se necesita un minimo de items en
* la matriz pasada por referencia. Completa con " "
*
if Vartype(xnMindef)#"N"
	xnMindef=0
endif
if vartype(nAncho)#"N"
	nAncho=70
endif
cFrase=alltrim(cFrase)
sbFrase=cFrase
* Si la frase es Vacio, vuelve de inmediato
if empty(cfrase)
	if xnMindef=0
		Dimension xaMatriz(1)
	else
		Dimension xaMatriz(xnMindef)
	endif
	Store "" to xaMatriz
	return
else
	*Revisar los puntos
	npuntos=Occurs(".",cFrase)
	if npuntos#0
		oFrase=""
		nlen=len(cFrase)
		dimension gapuntos(1)
		gpase=0
		ni=0
		do while .t.
			ni=ni+1
			if ni=nlen
				exit
			endif
			if Substr(cFrase,ni,1)="."
				cExa=Substr(cFrase,ni+1,1)
				if !INlist(cExa,Chr(32),".")
					cFrase=Substr(cFrase,1,ni)+" "+Substr(cFrase,ni+1)
					nlen=nlen+1
				endif
			endif
 
		enddo
 
 
	endif
endif
 
* Calcula cantidad de saltos y divide en gaParte
nspacios=Occurs(Chr(32),cFrase)
ntrece=Occurs(chr(13),cfrase)
nsaltos=Occurs(chr(10),cFrase)
ngap=iif(nSaltos<2,1,nSaltos)
 
 
* Antes decia ngap=iif(nsaltos<2,1,nTrece)
nis=0
Dimension gaParte(ngap)
if nGap=1
	gaparte[1]=cfrase
else
	xcFrase=cFrase
	do while .t.
		xngap=At(Chr(10),xcFrase)
		if xnGap=0
			exit
		endif
		nis=nis+1
		dimension gaParte(nis)
		gaParte[nis]=Left(xcFrase,xnGap-1)
		xcFrase=Substr(xcFrase,xnGap+1)
 
	enddo
	if !empty(xcFrase)
		nis=nis+1
		dimension gaparte(nis)
		gaParte[nis]=alltrim(xcFrase)
	endif
endif
 
for xi_=1 to alen(gaParte)
	gaparte[xi_]=VmChar(gaparte[xi_])
 
	if At(chr(13),gaParte[xi_])>0
		gaParte[xi_]=strtran(gaParte[xi_],chr(13),"")
	endif
	if At(chr(19),gaparte[xi_])>0
		gaparte[xi_]=Strtran(gaparte[xi_],chr(19))
	endif
next
nSumPerdi=0
Dimension xaMatriz(1)
nit=0
for xi=1 to alen(gaParte)
	sbFrase=alltrim(gaparte[xi])
	nspacios=Occurs(Chr(32),sbFrase)
	Lenfra=Len(sbFrase)
 
	IF LENFRA<=nAncho
		nit=nit+1
		dimension xaMatriz(nit)
		xaMatriz[nit]=sbFrase
	else
		if nSpacios>0
		*aPunto[] recoge las posiciones de aparición de Chr(32)
			Dimension aPunto(1)
			di=0
			for qi=1 to len(sbFrase)
				npun=At(Chr(32),sbFrase,qi)
				if npun=0
					exit
				endif
				di=di+1
				Dimension aPunto(di)
				aPunto[di]=npun
			next
			nLast=1
			cRest=sbFrase
			nSumlen=0
			nParte=nAncho
 
			For di=1 to alen(aPunto)
				keBodrio=""
				nRemp=aPunto[di]
				if aPunto[di]>=nParte
 
					cProye=Alltrim(Substr(sbFrase,nLast,aPunto[di]-nLast+1))
					nLastResta=0
					do while len(cProye)>nAncho
						nLastResta=nLastResta+1
						cProye=Alltrim(Substr(sbFrase,nLast,aPunto[di-nLastREsta]-nLast+1))
					enddo
					nit=nit+1
					Dimension xaMatriz(nit)
					xaMatriz[Nit]=cProye
					nSumLen=nSumLen+Len(xaMatriz[nit])
					nPerdido=nAncho-len(xaMatriz[nit])
					nSumPerdi=nSumperdi+nPerdido
					nLast=aPunto[di-nLastResta]+1
					nParte=nSumLen+nAncho+nSumPerdi
				endif
				* Ultima parte
				if di=alen(apunto)
					nit=nit+1
					Dimension xaMatriz(nit)
					xaMatriz[Nit]=Alltrim(Substr(sbFrase,nLast,lenfra-nLast+1))
				endif
 
			next
		else
			nSta=int(len(sbfrase)/nAncho)
			if Mod(Len(sbfrase),nAncho)#0
				nSta=nsta+1
			endif
			xSta=1
			zbFrase=sbfrase
			for fi=1 to nSta
				nit=nit+1
				dimension xaMatriz(nit)
				zbFrase=Substr(zbFrase,xSta)
				xaMatriz[nit]=Left(zbfrase,nAncho)
				xSta=xSta+nAncho
			next
		endif
	endif
next
if xnMindef>nit
	Dimension xaMatriz(xnMindef)
	for jo=Nit+1 to xnMindef
		xaMatriz[jo]=" "
	next
endif
nSepar=ALEN(xaMatriz)
IF nSepar=1.and.Empty(xaMatriz[1])
	nSepar=0
ENDIF
RETURN nSepar
endproc
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 1.011
Oro
Ha mantenido su posición en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

IMPRIMIR UN NOMBRE LARGO EN 2 LINEAS

Publicado por Fidel (558 intervenciones) el 26/09/2013 20:43:37
Mirando el código veo que se escapó una tal función VmChar().
gaparte[xi_]=VmChar(gaparte[xi_])
Si quieres usar SeparText(), quita esa línea. VmChar elimina caracteres no admitidos, pero si el texto es fiable no hará absolutamente nada.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar