Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need escape sequence to change font size in middle of pa
Message
De
23/04/2004 09:12:25
 
 
À
22/04/2004 19:11:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00897287
Message ID:
00897558
Vues:
22
Hi Alejandro,

>How would you do it in that case, Tracy?

We just send the codes for the HPLJ Series II. I will send you the dbf and cdx in email so you can browse the table and see.


>For all printers? Including laser?

Yes, you just add the codes for any printers you add to the table.

We have two tables. One table stores the report name and also contains the printer port (for FPD26) or the windows printer name (for the VFP app) and also the printer type. The printer type is linked to the printer table which contains the escape codes for that printer.

At the beginning of each report, we issue:
IF !PRINTSET('CONTRACT')  && this example for printing a contract
    RETURN .F.
ENDIF
Then in the printset.prg we locate the contract record in the reports table and determine which port or printer it should go to and which printer type to use.

For instance, if VFP, the contract record in the report table (we call it control) contains:
Report    Windows Printer Name (port)                 Printer Type
CONTRACT  \\NCSERVER\HP LaserJet  4000 Series PCL 6   HPLJ II (60 lpp) && vfp
CONTRACT  LPT2                                        HPLJ II (60 lpp) && dos 
The printset.prg program does more, it also sets the printer for the printjob and pulls any special commands, etc:
* Small example of getting the font size from the ptr_code table
* The ptr_table is related to the report table (control) on the printer type
* In printset.prg
m.av_cpi12   = ptr_code(m.av_cpi12)
m.av_lpi6    = ptr_code(m.av_lpi6)
m.av_lpi8    = ptr_code(m.av_lpi8)
opt      = ptr_code(control.cn_preprt)
resetopt = ptr_code(control.cn_postprt)

*ptr_code function
FUNCTION ptr_string
PARAMETERS ptr_string

PRIVATE pos,p_code

pos = 0			   && Position of comma
xpos = 0		   && Ending quote mark
p_code = ""		   && Actual printer code

*Start with p_code equal to the first number as a CHR()

IF !EMPTY(ptr_string)
	p_code = CHR(VAL(ptr_string))

	DO WHILE .T.
		pos = AT(",",ptr_string)
		IF pos = 0
			EXIT
		ENDIF
		IF SUBSTR(ptr_string,pos+1,1) = '"'
			xpos = AT('"',ptr_string,2)
			p_code = p_code + SUBSTR(ptr_string,pos+2,xpos-(pos+2))
			ptr_string = SUBSTR(ptr_string,xpos+1)
		ELSE
			ptr_string = SUBSTR(ptr_string,pos+1)
			p_code = p_code + CHR(VAL(ptr_string))
		ENDIF
	ENDDO
ENDIF

RETURN p_code
Then the printset table does the following:
#IF 'VISUAL' $ UPPER(VERSION())
	PRIVATE gnPos
	PRIVATE ARRAY gaPrinters(1,2)
	=APRINTERS(gaprinters)
	gnPos = ASCAN(gaPrinters,port) && Search for printer name

	IF LEN(ALLTRIM(port))=0 OR gnPos=0	&& not found
	   *--If no printer is setup,then use the default windows printer
	   port = SET('PRINTER TO',2)
	ENDIF

	port=LTRIM(port)

	SET PRINTER TO NAME (port)
		
	SET DEVICE TO PRINT
#ELSE
	IF !EMPTY(predos)
		RUN /64 &predos
	ENDIF

	SET PRINTER TO junk
	EJECT
		
	SET PRINT TO &port

	SET DEVICE TO PRINT
	IF !PRINTSTATUS()
	   SET DEVICE TO SCREEN
	   SET PRINT TO
	   SET PRINT TO
	   =okay("Printer is not ready.",7,0,'PORT: '+port)
	   xreturn = .F.
	ENDIF
#ENDIF
After the !PRINTSET command in the report program we would issue:
*A prg that prints a report
IF !printset("CONTRACT")
	RETURN
ENDIF

set console off
set printer on

??? opt
??? av_lpi8
??? av_cpi12
??? av_boldon
*etc
or something like:
IF !printset("ENDORSEMENT")
	RETURN .F.
ENDIF

WAIT WINDOW "Printing..." NOWAIT

??? opt
??? av_lpi8
??? av_stdprt
??? av_boldon
@   0,  0 SAY carrier.ca_name PICTURE 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
??? av_boldoff
@   0, 60 SAY ''
??? av_boldon
@   0, 60 SAY "CHANGE ENDORSEMENT"
??? av_boldoff
@   1,  0 SAY ''
??? av_boldon
@   1,  0 SAY RTRIM(carrier.ca_addr1)
??? av_boldoff
@   2, 48 SAY "CHANGE EFFECTIVE:"
*etc

After printing every report, we always issue:
#IF NOT 'VISUAL' $ UPPER(VERSION())
	EJECT

	??? av_stdprt
	??? resetopt
#ELSE
	IF !EMPTY(sFontStd)
		SET PRINTER FONT &sFontStd
	ENDIF
#ENDIF

DO prntrset 
RETURN

PROCEDURE prntrset
#IF 'VISUAL' $ UPPER(VERSION())

	*TB 07/15/2003
	SET PRINTER OFF

	SET CONSOLE ON
	SET DEVICE TO SCREEN
	SET PRINT TO

	*TB 07/15/2003
	SET PRINT TO

	*---Restore Screen
	DO ScrnRSet

#ELSE

	IF SET('PRINT') = 'ON'
		SET PRINT OFF
	ENDIF

	IF SET('CONSOLE') = 'OFF'
		SET CONSOLE ON
	ENDIF

	SET DEVICE TO SCREEN
	SET PRINT TO
	IF !EMPTY(postdos)
		RUN /64 &postdos
	ENDIF
#ENDIF
RETURN
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform