A printer can be assigned a device number between 256 and 2047, inclusive. This range of device numbers are also used for terminals and flat files.
On a Windows system, you can refer to a printer using its device number or an assigned device mnemonic. The Windows default printer mnemonic is |PRN|.
Opening a Printer
When opening a printer, you can use the device name to specify the device. The device name must be enclosed in quotes. The maximum length of this device name is 256 characters. The form is as follows:
On Windows, you can also have a printer attached to a serial communications port. In this case, the printer is treated the same as terminal I/O with the following syntax:
Where n is the port number to which the printer is attached.
Specifying a Printer on Windows
To use the default printer on Windows, enter the following:
This causes InterSystems IRIS to use the default Windows printer for your machine, if you have set the default printer for your machine. (For information on how to set the default printer, see your Windows documentation.)
To use a printer other than the default printer, enter the following:
||The Universal Naming Convention (UNC) name or a name that shows up on your machine's list of printers (Print Manager in Windows NT, 2000, and XP).
The following example illustrates the use of a UNC name:
The following example illustrates the use of a non-UNC name that might appear on your machine's list of printers:
OPEN "|PRN|HP LaserJet 5P"
InterSystems discourages the use of printer port names like COM1, LPT1, etc. If you do use such a name, InterSystems IRIS will try to figure out which printer, if any, that name refers to and then it will use that name. However, this will be a slow operation and is not really appropriate for Windows
On Windows systems, a printer is identified by the name on the OPEN command and is handled by the sequential I/O module, not the terminal I/O module. Thus the OPEN and USE command arguments supported are the same as those for sequential file I/O, not terminal I/O. The exception to this is a printer connected to a Windows system through a serial communications port; in this case, the printer is handled as a terminal I/O device.
On Windows systems, you cannot use the “:n” positional parameter to control the print margin used. Such notation is ignored by InterSystems IRIS. Code such as "|PRN|":121 is ignored. To control the printer width, send the appropriate control characters for that printer. The notation does work on other platforms.
On Windows, OPEN supports most of the sequential I/O keyword parameters, as described in the Sequential File I/O chapter of this manual. The following table describes additional printer keyword parameters for controlling a printer (handled as a sequential file) on Windows systems with the OPEN command.
Additional OPEN Keyword Parameters for Windows Printers
||/DOCNAME enables you to redefine the printer job name.
||/OUTPUTFILE redirects print to a file. Specify a fully-qualified pathname.
||/DATATYPE enables you to redefine the datatype of the printer spool data. One frequently-used datatype is TEXT.
On Windows systems, if the OPEN prints directly to the printer (does not use a logical spool device), the OPEN command timeout argument does not expire if the printer is turned off or does not exist. The InterSystems IRIS process remains in a suspended state until the printer becomes available, or until the print document is cancelled from the Windows Control Panel.
Specifying a Printer on UNIX®
To open an I/O device on a terminal that has the UNIX® device name /dev/tty06, enter the following command
On UNIX® systems, a printer is identified by the name on the OPEN command and is handled as a “character special” file on a tty device. Thus the OPEN and USE command arguments supported are the same as those for terminal I/O, not sequential file I/O.
On UNIX®, OPEN supports most of the terminal I/O keyword parameters, as described in the Terminal I/O chapter of this manual.