From VSI OpenVMS Wiki
Jump to: navigation, search

OPEN is a DCL command that opens a file for reading, writing, or both; assigns a logical name to a file; and places the name in the process logical name table.


OPEN  logical-name[:] filespec


  • /APPEND opens an existing file for writing and positions the record pointer at the end-of-file (EOF). New records are added to the end of the file. Only sequential files allow more than one user to append records concurrently. Use the /APPEND qualifier only to add records to an existing file. The /APPEND and the /WRITE qualifiers are mutually exclusive.
  • /ERROR=label transfers control to the location specified by the label keyword (in a command procedure) if the open operation results in an error. The error routine specified for this qualifier overrides any ON condition action specified. If the /ERROR qualifier is not specified, the current ON condition action is taken. If an error occurs and the target label is successfully given control, the global symbol $STATUS retains the code for the error that caused the error path to be taken.
  • /READ (default) Opens the file for reading. If you open a file with /READ, other users are also allowed read access to the file, but no user is allowed write access. If you open a file with /READ/WRITE, no other users are allowed access while the file is open. If you specify the /READ qualifier without the /WRITE qualifier, you must specify an existing file.
  • /SHARE=option opens the specified file as a shareable file to allow other users read or write access. If you specify the /SHARE=READ qualifier, other users are allowed read (R) access to the file, but not write (W) access. If you specify the /SHARE=WRITE or the /SHARE qualifier with no option, users are allowed read and write access to the specified file. To open a file with no shared access, specify /NOSHARE (Alpha and Integrity only) or use OPEN/READ/WRITE.
  • /WRITE opens the file for writing. The following restrictions apply to the /WRITE qualifier:
    • Use the /WRITE qualifier to open and create a new, sequential file. If the file specification on an OPEN/WRITE command does not include a file version number, and if a file with the specified file name and file type already exists, a new file with a version number one greater than the existing file is created.
    • Use the /READ qualifier with the /WRITE qualifier to open an existing file. While the file is open, no other user will have access to it. When the file is first opened, the pointer is positioned to the beginning of the file. (This differs from OPEN/APPEND, which positions the pointer at the end of the file.) You cannot use OPEN/READ/WRITE to create a new file.
    • The /WRITE and the /APPEND qualifiers are mutually exclusive.

Determining Open Files

A list of files open on a device can be viewed with SHOW DEVICE/FILES.

See also