I/O Device Guide
This chapter discusses how to configure and use print devices in InterSystems IRIS Data Platform™. A printer is a physical output-only device. A printer may be a character printer, or a non-character device such as a fax or plotter.
In most cases, output is not sent directly to a printer. Often, output to be printed is first sent to a logical spool device (the ^SPOOL global). The contents of the ^SPOOL global can then be sent to the physical printer. For further details on spooling, refer to the Spool Device
chapter of this manual.
Note that Windows and UNIX® handle printer I/O differently.
Windows systems handle a printer as a sequential I/O device, and thus follows the same syntax as sequential file I/O. However, a printer connected through a serial communications port is handled as a terminal I/O device.
UNIX® systems always handle a printer as a terminal I/O device. UNIX® treats it as a character special file on a tty device, and thus follows the same syntax as terminal I/O.
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|
There are two ways to specify a printer:
Call the %IS
utility, which allows you to specify the device by using a mnemonic defined in the %IS
global. This utility opens the device and sets its parameters.
Issue the I/O commands OPEN
, and CLOSE
, using the operating system device name, specified as a quoted string.
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:
OPEN "device" USE "device" CLOSE "device"
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:
is the port number to which the printer is attached.
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
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, 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
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
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.
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
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.
You can use the %IS utility to direct output to a printer. You can invoke the %IS utility with the command DO ^%IS
. (You can also use DO OUT^%IS
to specify that you are selecting an output-only device.) In either case, InterSystems IRIS returns the Device:
prompt. To specify a printer, reply with either the default mnemonic "|PRN|", or the mnemonic of another configured printer. The %IS utility then suggests OPEN parameters; for a printer, the default is W (write-only). You can accept the parameter default by pressing Enter
, as shown in the following example:
Parameters? "W" => <RETURN>
This opens the specified printer as an output device for the current process.
The %IS utility sets various variables. The following are the printer default values on a Windows system.
Variables Set by %IS
||Device mnemonic of selected device.
||Form feed character. WRITE # issues a form feed and changes $Y. WRITE @IOF should be used to form feed.
||Backspace/overprint character (ASCII 8). WRITE $CHAR(8) issues a backspace and changes $X. WRITE *8 issues a backspace but does not change $X. WRITE @IOBS should be used to backspace.
||Right margin; line length in characters.
||Page length in characters.
||Device type. Here Other.
||Device subtype name.
||OPEN parameters. Here W because a printer is a write-only device.
||Type of system (such as UNIX® or Windows NT). M/WNT is InterSystems IRIS on Windows NT.
||Indicates that %IS was run (and these variables initialized). If 0, a device was specified. If 1, no device was specified (user entered STOP in response to the Device: prompt).
When you call %IS for spooling, you can pass it the IOPGM variable, which specifies the name of the routine that sets up printer forms alignment.
You can specify a printer as the alternate device for all processes by defining a new device named A and specifying a physical device of |PRN|. Then when you use %IS, specify A at the Device:
Content Date/Time: 2019-04-10 14:45:56