APRINTERS( ) Function

Stores information about currently-available printers into an array.

Note

The behavior of this function is OS (operating system) - specific. Visual FoxPro may or may not check to see if the printers are actually connected to your computer when it prepares this list, and the list may include all printers installed as printer setups, or only those available on the current network.

APRINTERS(ArrayName [, nValue])

Parameters

  • ArrayName
    Specifies the name of the array containing information about printers.

    Note

    If the array you include does not exist, Visual FoxPro automatically creates the array. If the array exists but is not large enough to contain all the information, Visual FoxPro increases the size of the array to accommodate the information. If the array is larger than necessary, Visual FoxPro truncates the array. If the array exists but APRINTERS( ) returns 0 because no printers are available, the array remains unchanged. If the array does not exist, and APRINTERS( ) returns 0, the array is not created.

  • [, nValue]
    Specifies a value that creates a two-column array or five-column array. Each row in the array contains information about a printer.

    The following table describes the possible values of nValue.

    nValue

    Description

    0 or omitted

    Return a two-column array containing the following items beginning with the first column:

    • Printer name.

    • Name of the port to which the printer is connected.

    1

    Return a five-column array containing the following items beginning with the first column:

    • Printer name.

    • Name of the port to which the printer is connected.

    • Name of the printer driver.

    • Printer comment.

    • Printer location.

Return Value

Numeric. APRINTERS( ) returns the number of rows in the array or 0 when no printers are available.

Example

The following example creates an array named gaPrinters if any printers are available and displays information about those printers. Otherwise, it displays a message indicating that APRINTERS( ) is unable to retrieve information about any printers.

IF APRINTERS(gaPrinters) > 0  
   CLEAR  && clear the current output window
   DISPLAY MEMORY LIKE gaPrinters && show the contents of the array
ELSE  
   WAIT WINDOW 'No printers found.'
ENDIF

See Also

Reference

GETPRINTER( ) Function

PRINTSTATUS( ) Function

PRTINFO( ) Function

SET PRINTER Command

Other Resources

Functions

Language Reference (Visual FoxPro)