Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Specify printer tray or bin to print report to programma
Message
De
06/04/2006 10:40:53
 
 
À
01/04/2006 22:39:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00808875
Message ID:
01110991
Vues:
26
Hi Roy,

One way would be to use the value pulled from the getprintertray program and then do this (works on my workstation using an HP LaserJet 4 - the value 257 is returned from the getprintertrays program and represents the manual feed paper bin):

*--ChangePrinterTray.PRG Example
*--Create a report called TestReport that prints the testt.cname and testt.cid fields

SET SAFETY OFF
CLOSE ALL
CLEAR ALL

CREATE TABLE testt (cname c(30), cid c(10))
i = 0
FOR i = 1 TO 10f
   SELECT testt
   APPEND BLANK
   REPLACE testt.cname WITH "Name"+PADL(ALLTRIM(STR(i)),2,'0')
   REPLACE testt.cid WITH PADL(ALLTRIM(STR(i)),10,'0')
ENDFOR
SELE testt

*--Set the report variable and any offset or bin number
lcReportForm = "TestReport"
toffSet = 2
tBin = 257                      && This value was pulled from the getprintertrays utility
tdir = LEFT(SYS(2005),RAT("\",SYS(2005)))
hdir = LEFT(SYS(2005),RAT("\",SYS(2005)))

*--This is just for this example to test
lcPrinter = GETPRINTER()
SET PRINTER TO NAME (lcprinter)

DO PrintRep WITH lcReportForm, '', '', 0, 0, 0, .F., toffset, tBin

CLOSE TABLES
RETURN


*-----------------------------------------------------------------------------------------------------
FUNCTION PrintRep
PARAMETER sReportName, forclause, prescope, iLength, iBottomarg, iNumCopies, bCondensed, iOffset, iBin

IF EMPTY(sReportName)
   RETURN
ENDIF

PRIVATE xrep, mforclause, iWidth
mforclause = .T.
iWidth = 80

IF EMPTY(forclause)
   forclause = "mforclause"
ENDIF
IF EMPTY(prescope)
   prescope = 'ALL'
ENDIF
IF EMPTY(iLength)
   iLength = 0
ENDIF
IF EMPTY(iBottomarg)
   iBottomarg = 0
ENDIF
IF EMPTY(iNumCopies)
   iNumCopies = 0
ENDIF
IF EMPTY(iOffSet)
   iOffSet = 0
ENDIF
IF EMPTY(iBin)
   iBin = 0
ENDIF

xrep=REPTMODI(sReportName, iLength, iBottomarg, @iWidth, iNumCopies, iOffset, iBin)

IF !EMPTY(xrep)

   m.canceled = .F.

   SET ESCAPE ON
   ON ESCAPE m.canceled = yesno("Cancel Printing?",5)

   REPORT FORM (xrep) &prescope WHILE NOT m.canceled FOR &forclause TO PRINTER NOCONSOLE

   SET CONSOLE ON

   ON ESCAPE
   SET ESCAPE OFF
   
   DELETE FILE (xrep+".frx")
   DELETE FILE (xrep+".frt")
ELSE
   =MESSAGEBOX('REPORT FORM NOT FOUND: '+sReportName)
ENDIF

RETURN


*-------------------------------------------------------------------------
FUNCTION reptmodi
PARAMETER xreport,pagesize,bottmarg,ywidth,iCopies,toffset,iBin

IF EMPTY(toffset)
   toffset = 0
ENDIF
private newname,crntalias, lfintop
crntalias = ALIAS()
newname = tdir+SYS(3)
SELECT 0
USE (xreport+".frx")
COPY TO (newname+".frx")
* Check to see if file was created and then process
lfintop = .F.

IF FILE(newname+".frx")
   USE (newname+".frx")
   SCAN
   
      IF !lfintop .and. OBJTYPE = 1
         IF !EMPTY(pagesize)
            REPLACE HEIGHT WITH pagesize
         ENDIF
         IF !EMPTY(bottmarg)
            REPLACE BOTMARGIN WITH bottmarg
         ENDIF
         IF !EMPTY(iCopies) AND TYPE('EXPR') <> 'U'
            REPLACE EXPR WITH STRTRAN(EXPR, 'COPIES=1', 'COPIES=' + ALLTRIM(STR(iCopies)))
         ENDIF
         IF !EMPTY(iBin) AND TYPE('EXPR') <> "U"
            IF 'DEFAULTSOURCE=' $ EXPR
               REPLACE EXPR WITH STRTRAN(EXPR, 'DEFAULTSOURCE=', 'DEFAULTSOURCE=' + ALLTRIM(STR(iBin)))
            ELSE
               REPLACE EXPR WITH EXPR + 'DEFAULTSOURCE='+ALLTRIM(STR(iBin))
            ENDIF
         ENDIF
         
         ywidth = WIDTH
         lfintop = .T.
      ENDIF
      
      IF toffset <> 0
         IF OBJTYPE > 4 .and. OBJTYPE < 20
            lnolddecimals = SET('DECIMALS')
            SET DECIMALS TO 3
            idiff = 900.050 * toffset
            REPLACE vpos WITH vpos + idiff
            SET DECIMALS TO (lnolddecimals)
         ENDIF
      ENDIF
     
   ENDSCAN
   USE
ELSE
   newname = ""
ENDIF

IF !EMPTY(crntalias)
   SELECT (crntalias)
ENDIF

RETURN newname
.·*´¨)
.·`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
Répondre
Fil
Voir

Click here to load this message in the networking platform