PrinterCount, PrinterName, PrinterInfo Properties (App)

Purpose

These properties enable you to gather information about all the available printers on the system.

Syntax

%= App.PrinterCount

$ = App.PrinterName(i%)

v = App.PrinterInfo(Printer$, What$)

v:Variant

Description

The PrinterCount property returns the number of printers available.

The PrinterName(i) property returns the name of the printer with index i%.

The PrinterInfo(Printer$, What$) property returns the device mode information What$ of the printer with name Printer$. Many printer features are device dependent, For example, not all printers support all paper sizes or support landscape printing. You have to actually check the parameters. This device-dependent information is found in the DEVMODE structure. The What$ parameter takes (some of) the DEVMODE members as a string and PrinterInfo returns the value as a Variant. The following entries can be used for What$:

Dim p$ = App.PrinterName(1)

Trace App.PrinterInfo( p$, "Driver")

Trace App.PrinterInfo( p$, "Orientation")

Trace App.PrinterInfo( p$, "PaperSize")

Trace App.PrinterInfo( p$, "PaperLength")

Trace App.PrinterInfo( p$, "PaperWidth")

Trace App.PrinterInfo( p$, "Copies")

Trace App.PrinterInfo( p$, "Quality")

Trace App.PrinterInfo( p$, "Color")

Trace App.PrinterInfo( p$, "Duplex")

Trace App.PrinterInfo( p$, "PaperBin")

Example

The following code searches all available printers to locate the first printer with its page orientation set to portrait, then sets it as the default printer:

Dim pr$, i%

For i = 0 To App.PrinterCount - 1

pr$ = App.PrinterName(i)

Print pr$

If App.PrinterInfo(pr$, "Orientation") = 1

SetPrinterByName pr$

Exit For

EndIf

Next

Remarks

SetPrinterByName implicitly invokes Set Printer =.

GFA-BASIC 32 does not provide a Printers collection, instead you should use the App properties to enumerate the printers attached to system.

See Also

App, Printer, SetPrinterByName

{Created by Sjouke Hamstra; Last updated: 21/10/2014 by James Gaite}