*--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