Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sending to Multiple Printer
Message
From
21/11/2002 13:53:32
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00725358
Message ID:
00725380
Views:
10
We do something like this. We allow the users to send every report to a specific printer if necessary and more than one printer, or numerous copies too. How we do it is we keep a 'control' table with a list of reports in it and two fields that hold the printer names in windows. We have two fields for the printer names instead of multiple records for the same report with a different printer name in each record because we've never had to print to more than two printers. First the user calls the printset function which locates the report name in the control table and pulls the printer name from it. Then the user prints the report.

Here is a condensed version:
*--Report Program
PRIVATE lcprintera, lcprinterb, lnumcopiesa, lnumcopiesb
lcprintera=""
lcprinterb=""
lnumcopiesa=0
lnumcopiesb=0

*--Get the printer names and store them in lcprintera and lcprinterb
*--Get the number of copies to print to each printer
myreport="TRANSMITTALS"
IF !PRINTSET(myreport)
   RETURN .F.
ENDIF

IF !EMPTY(lcprintera)
    FOR i = 1 TO lnumcopiesa
        REPORT FORM (myreport) TO PRINTER NOCONSOLE
    ENDFOR
ENDIF
IF !EMPTY(lcprinterb)
    SET PRINTER TO NAME (lcprinterb)
    FOR i = 1 TO lnumcopiesb
        REPORT FORM (myreport) TO PRINTER NOCONSOLE
    ENDFOR
ENDIF

DO prntrset

RETURN

*---------------------------------------------
FUNCTION printset
PARAMETERS seekonthis
IF PCOUNT()=0
   RETURN .F.
ENDIF
LOCAL iscontrolopened
iscontrolopened=.F.
IF USED('CONTROL')
	SELECT Control
	SET ORDER TO TAG name IN CONTROL
ELSE
	SELECT 0
	#IF 'VISUAL' $ UPPER(VERSION())
	
		IF !FILE(hdir+'lcontrol.dbf')
			DO CreateLocalCtrl
		ENDIF

		USE (hdir+'lcontrol.dbf') ALIAS control ORDER TAG name
		
	#ELSE
		USE (ddir+sys_control) ALIAS control ORDER TAG name
	#ENDIF
	iscontrolopened = .T.
ENDIF
IF !SEEK(seekonthis,"CONTROL")
	xreturn = EditCtrl("Control Record '"+seekonthis+"' was not found.  Do you wish to add the record?")
	#IF 'VISUAL' $ UPPER(VERSION())
		IF !xreturn
			IF iscontrolopened
				USE IN control
			ENDIF

			IF !EMPTY(dbfarea)
				SELECT (dbfarea)
			ENDIF

			RETURN xreturn
		ENDIF
	#ENDIF
ENDIF
xreturn = .T.
IF !EMPTY(control.printera)
    STORE control.printera TO lcprintera
ENDIF
IF !EMPTY(control.printerb)
    STORE control.printerb TO lcprinterb
ENDIF
IF !EMPTY(control.acopies)
    STORE control.acopies TO lnumcopiesa
ENDIF
IF !EMPTY(control.bcopies)
    STORE control.bcopies TO lnumcopiesb
ENDIF
IF iscontrolopened
    USE IN control
ENDIF
IF !EMPTY(lcprintera)  && valid printer name?
    SET PRINTER TO NAME (lcprintera)
    SET DEVICE TO PRINT
    IF !PRINTSTATUS()
	SET PRINT TO
	SET DEVICE TO SCREEN
	=okay("Printer is not ready.",7,0,'PORT: '+port)
	xreturn = .F.
    ENDIF
ELSE
    xreturn = .F.
ENDIF
RETURN xreturn

*---------------------------------------------
PROCEDURE prntrset
#IF 'VISUAL' $ UPPER(VERSION())
	SET CONSOLE ON
	SET DEVICE TO SCREEN
	SET PRINT TO
	ACTIVATE SCREEN

	WITH _screen
		.lockscreen=.T.
		.fontname=glFontName
		.fontsize=glFontSize
		.fontunderline=.f.
		.fontbold=.f. 
		.BackColor = cOldbackcolor
		.ForeColor = cOldforecolor
		.FillColor = cOldfillcolor
		.lockscreen = .F.
	ENDWITH

#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
>Client request that when then send a report to print, a particular report in this case, that is get printed to two additional printers at the same time. So I was thinking I could store the printer string from the getprinters() function into a table. Then when they hit the print button, I could send it to each one. First...is this a sensable way to do it, and number two, can the "Report form" command send it to a specific printer, or do I have to issue a set printer to, report form, set printer to, report form and then set it back to what is was before. And how can I get what it was before?
>
>Thanks
>Kirk
.·*´¨)
.·`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"
Previous
Reply
Map
View

Click here to load this message in the networking platform