Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

Parameters

Command Qualifiers

Examples

/APPEND

/ERROR

/READ

/SHARE

/WRITE

HELP OPEN — VMS 4.6

  Opens a file for reading and/or writing.  When opening a  file,  the
  OPEN command assigns a logical name to a file and places the name in
  the process logical name table.

  Format:


    OPEN  logical-name[:] file-spec

Additional information available:

ParametersCommand QualifiersExamples

Parameters

 logical-name[:]

  Specifies a logical name to be assigned to the file.

 file-spec

  Specifies the name of the file or device to be opened for  input  or
  output.  If the file specification does not include a file type, the
  system uses the default file type of DAT.

  If you specify a file that does not exist, you can  use  the  /WRITE
  qualifier  to create a new, sequential file.  See the description of
  the /WRITE qualifier for more information.

  No wildcard characters are allowed in the file specification.

Command Qualifiers

Additional information available:

/APPEND/ERROR/READ/SHARE/WRITE

/APPEND

 /APPEND

 Requests that an existing file be opened for  writing  and  that  the
  record  pointer  be  positioned at the end-of-file.  Any new records
  are added to the end of the file.

  You can use the /APPEND qualifier only to add records to an existing
  file.  The /APPEND and the /WRITE qualifiers are mutually exclusive.

/ERROR

 /ERROR=label

 Specifies a label on a line  in  the  command  procedure  to  receive
  control  if the open request results in an error.  The error routine
  specified for the /ERROR qualifier takes precedence over any  action
  statement  indicated  in an ON command.  If /ERROR 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

 /READ

 Requests that the file be opened for reading.  This is the default if
  you do not specify either /READ or /WRITE.  If you specify the /READ
  qualifier without the /WRITE qualifier, you must specify an existing
  file.

/SHARE

 /SHARE[=option]

 Requests that the specified file be opened as  a  shareable  file  to
  allow other users read or write access.  If you specify /SHARE=READ,
  users  are  allowed  read  access  to  the  file.   If  you  specify
  /SHARE=WRITE  or  omit  the option, users are allowed read and write
  access to the specified file.

/WRITE

 /WRITE

 Requests  that  the  file  be  opened  for  writing.   The  following
  restrictions apply to the /WRITE qualifier:

  o  You can use the /WRITE qualifier to open and create a  sequential
     file  if you specify a file that does not exist and if you do not
     also use the /READ qualifier on the command line.   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, the OPEN/WRITE command creates a new
     file with a version number one greater than the existing file.

  o  You can use the /READ qualifier with the /WRITE qualifier to open
     an  existing  file.   When  the  file  is  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.

  o  The /WRITE and the /APPEND qualifiers are mutually exclusive.

  o  If you specify both the  /WRITE  and  /SHARE  qualifiers  with  a
     sequential  file,  the  file  must  contain fixed-length 512-byte
     records.

Examples

  1.   $ OPEN INPUT_FILE AVERAGE.DAT
       $ READ_LOOP:
       $ READ/END_OF_FILE=ENDIT  INPUT_FILE  NUM
          .
          .
          .

       $ GOTO READ_LOOP
       $ ENDIT:
       $ CLOSE INPUT_FILE

  The OPEN command opens the file named AVERAGE.DAT as an  input  file
  and assigns it the logical name INPUT_FILE.  The file is opened with
  read access because the /READ qualifier is present by default.   The
  READ  command  reads  a record from the logical file INPUT_FILE into
  the symbol named NUM.  The procedure executes the lines between  the
  labels READ_LOOP and ENDIT until the end of the file is reached.  At
  the end of the file, the CLOSE command closes the file.

  2.   $ OPEN/READ INPUT_FILE TRNTO::DBA0:[COST]INVENTORY.DAT
       $ READ_LOOP:
       $ READ/END_OF_FILE=ENDIT  INPUT_FILE  NUM
       $ FIRST_CHAR = F$EXTRACT(0,1,NUM)
       $ WRITE SYS$OUTPUT FIRST_CHAR
       $ GOTO READ_LOOP
       $ ENDIT:
       $ CLOSE INPUT_FILE

  This command procedure  opens  the  file  INVENTORY.DAT  located  at
  remote  node TRNTO as an input file, and assigns it the logical name
  INPUT_FILE.  The READ command reads a record from the  logical  file
  INPUT_FILE into the symbol named NUM.  The next two commands extract
  the first character from the record and write the character  to  the
  SYS$OUTPUT  device.   These  two  steps occur for all records in the
  file until the procedure reaches the end-of-file.   At  this  point,
  the  CLOSE  command  closes  the file and deassigns the logical name
  INPUT_FILE.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026