Microsoft KB Archive/154064

= How to direct output to installed GX printers =

Article ID: 154064

Article Last Modified on 2/11/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q154064



SUMMARY
Controlling what printer a program prints to can be accomplished through code with the enhancements to the SET PRINTER TO command in Visual FoxPro run with QuickDraw GX and some other new functions. This article provides a sample program combining the SYS(1038), the JustCSName and the SET PRINTER TO NAME enhancements to illustrate how to control which printer a report is printed to.

NOTE: QuickDraw GX is manufactured by a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding the performance or reliability of QuickDraw GX.

QuickDraw GX is not supported in Macintosh OS 8 and this sample program will not work with Visual FoxPro running under OS 8.



Sample Program
The following sample program assumes that QuickDraw GX is installed, that at least two printers are set up, and that their icons are on the desktop: *** Beginning of sample program IF SYS(1038) desktop=SUBSTR(SYS(2033),1,AT(':',SYS(2033)))+"\Desktop Folder\" numPrinters=ADIR(prtList, desktop+"*.*",'','dvcf') SET LIBRARY TO HOME+"FoxTools.cfm" ADDITIVE FOR x=1 TO numPrinters SET PRINTER TO NAME JustCSName(desktop+prtList[(x),1]) REPORT FORM "somereport.frx" NOEJECT NOCONSOLE TO PRINTER ? SET("Printer",2) ENDFOR SET LIBRARY TO  ENDIF *** End of sample program

Program Commentary
The first line in the program checks to see if QuickDraw GX is installed by using the SYS(1038) function.

The second line determines the name of the Macintosh's hard drive by using the SYS(2033) function, and appends "Desktop Folder" to it.

The third line checks to see how many QuickDraw GX printer icons are on the desktop and stores their names in an array named "prtList". The 'dvcf' in the fourth argument of the ADIR function is the creator type of the QuickDraw GX printer icons.

The fourth line loads the FoxTools.cfm library, which is necessary for the use of the JustCSName function.

The fifth line is the beginning of a FOR loop that executes once for each QuickDraw GX printer icon found on the desktop.

The sixth line (the first one in the FOR loop) sets the printer to one of the QuickDraw GX printers found on the desktop.

The seventh line prints a predefined report.

The eighth line reports the name of the current QuickDraw GX printer to the current output device (the Visual FoxPro screen).

