Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change print tray on-the-fly

Reports

Change print tray on-the-fly

by  Mike Gagnon  Posted    (Edited  )
DO CHANGETRAY WITH "C:\myreport.FRX", 1 && OR WHATEVER TRAY YOU WANT
Code:
FUNCTION CHANGETRAY
LPARAMETER lcFRX, lnTray
LOCAL lcNewExpr, lnStartCopiesLine, lcStartAtCopiesLine, lnEndCopiesLine ;
	lnLenCopiesLine, lcTop, lcBottom
#DEFINE vfCRLF CHR(13) + CHR(10)

IF !(UPPER(RIGHT(lcFRX, 4)) = ".FRX")
	lcFRX = lcFRX + ".FRX"
ENDIF
USE (lcFRX)
LOCATE FOR objType = 1 AND objCode = 53

IF EMPTY(EXPR)

	lcNewExpr = "DEFAULTSOURCE=" + ALLT(STR(lnTray)) + vfCRLF
ELSE

	lnStartCopiesLine = ATC("DEFAULTSOURCE", EXPR)
	lcStartAtCopiesLine = SUBSTR(EXPR, lnStartCopiesLine)
	lnEndCopiesLine = ATC(vfCRLF, lcStartAtCopiesLine)
	lnLenCopiesLine = LEN(SUBSTR(lcStartAtCopiesLine, 1, lnEndCopiesLine))
	lcTop = SUBSTR(EXPR, 1, lnStartCopiesLine - 1)
	lcBottom = SUBSTR(EXPR, (LEN(lcTop) + lnLenCopiesLine))
	lcNewExpr  = lcTop + "DEFAULTSOURCE=" + ALLT(STR(lnTray)) + lcBottom

ENDIF

REPLACE EXPR WITH lcNewExpr
USE IN (lcFRX)
ENDFUNC

Mike Gagnon
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top