Article ID: 47971
Article Last Modified on 11/21/2006
This article was previously published under Q47971
SUMMARY
When you open the printer device from your QuickBASIC program with OPEN "LPT1:PROMPT" FOR OUTPUT AS #n, two dialog boxes appear that allow you to set printer options at run time.
The sample program below shows how to read the "LPT1:PROMPT" options selected in the dialog boxes.
This information applies to Microsoft QuickBASIC Version 1.00 for the Apple Macintosh.
MORE INFORMATION
Page II-147 of "Inside Macintosh, Volume II" (published by Addison-Wesley, 1985) describes the Print Manager and shows the record structure for the Print Record and Dialogs. Your application should not change the data in the Print Record. Attempting to set other values directly in the Print Record can produce unexpected results.
Code Example
OPEN "lpt1:prompt" FOR OUTPUT AS #1 CALL GetPrintRecord CALL ShowPrintRecord CLOSE WHILE MOUSE(0)<> 1 :WEND END SUB GetPrintRecord STATIC SHARED hPrint&, fLaser, iVRes, iHRes, iFstPage, iLstPage, iCopies IF SYSTEM(4) = 0 THEN IF SYSTEM(2) <> 4 THEN PRINT "Must use Microsoft QuickBASIC Version 1.00" BEEP : STOP END IF PrintHandle& = -6180 GloblPtr& = PEEKL(&H904) ELSE DIM GlobalCode%(4) GlobalCode%(0) = &H226F 'MOVEA.L 4(A7),A1 GlobalCode%(1) = &H4 GlobalCode%(2) = &H2288 'MOVE.L A0,(A1) GlobalCode%(3) = &h4E75 'RTS GetGlobal& = VARPTR(GlobalCode%(0)) CALL GetGlobal&(VARPTR(GloblPtr&)) 'Get base of global storage PrintHandle& = 3626 'Offset to printer variable ERASE GlobalCode% END IF hPrint& = PEEKL(GloblPtr&+PrintHandle&) IF hPrint& <> 0 THEN pPrint& = PEEKL(hPrint&) iPrVersion = PEEKW(pPrint&) iDev = PEEKW(pPrint& + 2) iVRes = PEEKW(pPrint& + 4) iHRes = PEEKW(pPrint& + 6) rPageTop = PEEKW(pPrint& + 8) rPageLeft = PEEKW(pPrint& + 10) rPageBottom = PEEKW(pPrint& + 12) rPageRight = PEEKW(pPrint& + 14) rPaperTop = PEEKW(pPrint& + 16) rPaperLeft = PEEKW(pPrint& + 18) rPaperBottom = PEEKW(pPrint& + 20) rPaperRight = PEEKW(pPrint& + 22) wDev = PEEKW(pPrint& + 24) fLaser = 0 IF (wDev AND &HF00) = &H300 THEN fLaser = -1 prJob& = pPrint& + 62 iFstPage = PEEKW(prJob&) iLstPage = PEEKW(prJob& + 2) IF fLaser THEN iCopies = PEEKW(pPrint& + 46) ELSE iCopies = PEEKW(pPrint&+ 66) END IF END IF END SUB SUB ShowPrintRecord STATIC SHARED hPrint&, fLaser, iVRes, iHRes, iFstPage, iLstPage, iCopies IF hPrint& <> 0 THEN PRINT "Print Manager Version = ";iPrVersion PRINT "Printer is "; IF fLaser THEN PRINT "a LaserWriter" ELSE PRINT "an ImageWriter" END IF PRINT "Vertical resolution = ";iVRes PRINT "Horizontal resolution = ";iHRes PRINT "First page = "; iFstPage PRINT "Last page = "; iLstPage PRINT "# Copies = ";iCopies ELSE PRINT "No Print Record allocated" END IF END SUB
Additional query words: MQuickB
Keywords: KB47971