The function retrieves either the number of printers in the operating system or the name of a specified printer.
Declaration
INT | TEXT %GetPrinterName(
INT in _printerIdx
INT in _propIdx := 0
)
Parameters
_printerIdx
Serial number of printer (1, ...).
_propIdx
Optional parameter - type of information to be retrieved. Possible values:
0 - whole name of printer in the \\srvName\printerName format
1 - name of printer
2 - name of server in the \\srvName format
Description
After the function is called for the first time, it retrieves a list of printers defined in the operating system.
That list is to be stored within the D2000 system and the function can retrieve an information on printers from it.
Behaviour of the function depends on the value of the parameter _printerIdx as follows:
_printerIdx=-1 - the function rereads (refresh) the list of printers in the operating system and returns this number
(the parameter _propIdx is ignored)
_printerIdx=0 - the function retrieve the number of printers (the parameter _propIdx is ignored)
_printerIdx=1, 2, 3, ... - the function retrieves required information (specified by the parameter _propIdx)
on the given printer
If both the parameters contains incorrect value the function generates the _ERR_RANGE_ERROR string.
Note
The function can be used for Windows platforms only.
Example
BEGIN
;
INT _nrPrinters
INT _pIdx
;
TEXT _printerFullName
TEXT _printerName
TEXT _serverName
; retrieve the number of printers in operating systems
_nrPrinters := %GetPrinterName(-1)
; retrieve information on each printer
FOR _pIdx=1 TO _nrPrinters DO_LOOP
_printerFullName := %GetPrinterName(_pIdx, 0)
_printerName := %GetPrinterName(_pIdx, 1)
_serverName := %GetPrinterName(_pIdx, 2)
END_LOOP
;
END