Skip to main content

Specifying Devices in I/O Commands

When you use the I/O commands OPEN, USE and CLOSE to process I/O on any device other than the one on which you are working, you must specify an I/O device. You can specify devices in one of three ways, depending on device type, as shown in the table below.

Specifying a Device in an I/O Command
Type of Specification Use for these Devices
InterSystems IRIS Device Name Terminals and Printers
InterSystems IRIS Device ID or Device Alias All devices except sequential files
File Name Sequential Files

Note that Windows and UNIX® handle printer I/O differently. For details, refer see Printers.

Specifying Terminals and Printers by Device Name

If your I/O operations are to terminal (or a printer on some platforms), you can use the device name applied by the operating system (UNIX® or Windows) to specify the device. The form is as follows:

OPEN "device"  
USE "device"  
CLOSE "device"

Where device is the operating system name of the device, enclosed in quotes. The maximum length of device is 256 characters.

Specifying a Terminal on Windows Systems

To open an I/O device connected to a serial communications port, specify an OPEN command with the following syntax:

OPEN "comn:"

Where n represents the number of the port to which the device is attached.

   OPEN "com1:"

Specifying Terminals and Printers on UNIX®

To open an I/O device on a terminal that has the UNIX® device name /dev/tty06, enter the following command

   OPEN "/dev/tty06"

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 Windows systems, printer I/O is handled like sequential file I/O.

Specifying Devices by InterSystems IRIS ID

For compatibility with other InterSystems products and for convenience, you can refer to devices by device numbers (which are stored in the device table). The system manager can link these numbers to devices using the Management Portal. Select System Administration, Configuration, Device Settings, Devices to create a new device or edit an existing device.

The system manager can also cause a translation from one number to another. Thus, you can issue an OPEN 47 and InterSystems IRIS will translate it to OPEN 49.

The following table shows the device numbers.

InterSystems IRIS Device Numbers and Devices
Device Numbers Devices
0 Principal device (the device on which you logged in).
2 InterSystems IRIS spooler. UNIX®: the mnemonic SPOOL applies to this device.
3 An invalid device number. Attempting to open it returns a <NOTOPEN> error without waiting for timeout expiration.
63 View buffer.
20-46, 200-223 Routine interlock devices.
224-255 Interjob communication devices.

Examples

To open the spooler, you issue the command:

   OPEN 2

Specifying Files on Disk

You can open a disk file using the operating system file specification enclosed in double quotes.

A Windows file specification has the following format:

device:\directory\file.type

A UNIX® file specification has the following format:

/directory/name

For further details, see Specifying a File.

UNIX Examples

If your current default directory on a UNIX® or Windows system is /usr/user, you can open a file named pat_rec.dat stored in your current default directory by specifying:

   OPEN "pat_rec.dat"

The system opens the file automatically. For a new file, include the parameter string WN to avoid a hang.

To open a file with the same name, pat_rec.dat, stored in another directory, you must also specify the directory, as follows:

   OPEN "/usr/elsewhere/pat_rec.dat"
FeedbackOpens in a new tab