Open

The OPEN command establishes a connection from a GT.M process to a device.

The format of the OPEN command is:

	O[PEN][:tvexpr] expr[:[(keyword[=expr][:...])][:numexpr][:expr]][,...]
	

With the exception of mailboxes, spooled devices and SHARED sequential disk files, VMS device access is exclusive. READONLY sequential disk files may be shared among many readers, but no writers. Spooled devices are devices, usually printers, which buffer output from multiple sources, processing it after the writing process CLOSEs the file. Spooled devices appear to GT.M as a terminal type device. For more information on spooled devices, refer to the OpenVMS System Manager’s Manual. When one process successfully OPENs a device exclusively, no other process can access that device until the first process CLOSEs that device.

By default, when a device is unavailable, GT.M retries the OPEN indefinitely at approximately one second intervals. A device is unavailable when another process is using it exclusively, or when the OPENing process does not have the resources left to open the device.

All other errors on OPEN raise an error condition and interrupt program flow. A timeout is a tool that lets a GT.M routine regain program control when a device remains unavailable. When the OPEN specifies a timeout, GT.M keeps retrying until either the OPEN succeeds or the timeout expires.

If OPEN establishes a connection with a device before the timeout expires, GT.M sets $TEST to TRUE (1). If the timeout expires, GT.M sets $TEST to FALSE (0). If an OPEN command does not specify a timeout, the execution of the command does not affect $TEST.

If a process has not previously OPENed a device within the context of an image, any deviceparameters not supplied on the OPEN take their default values. When reOPENing a device that it previously closed, a GT.M process restores all characteristics not specified on the OPEN to the values the device had when it was last CLOSEd, except with sequential disk files. If you have a menu-driven application that OPENs and CLOSEs devices based on user selections, take care that every OPEN explicitly includes all deviceparameters important to the application.

GT.M treats sequential disk files differently and uses defaults for unspecified sequential disk file characteristics on every OPEN (i.e., GT.M does not retain sequential disk file characteristics on a CLOSE).

VMS does not permit the alteration of certain characteristics once the device or file has been OPENed. If a process OPENs an already OPEN device, GT.M modifies any characteristics that accept changes when a device is OPEN to reflect any new deviceparameter specifications.