HELPLIB.HLB  —  OPEN  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/WRITE/ERROR=OPEN_ERROR  OUTPUT_FILE  TEMP.OUT
      $ COUNT = 0
      $ WRITE_LOOP:
      $ COUNT = COUNT + 1
      $ IF COUNT .EQ. 11 THEN GOTO ENDIT
      $ WRITE OUTPUT_FILE "Count is ''COUNT'."
         .
         .
         .
      $ GOTO WRITE_LOOP
      $ ENDIT:
      $ CLOSE OUTPUT_FILE
      $ EXIT
      $
      $ OPEN_ERROR:
      $ WRITE SYS$OUTPUT "Cannot open file TEMP.OUT"
      $ EXIT

      The OPEN command with the /WRITE qualifier creates the file
      TEMP.OUT and assigns it the logical name OUTPUT_FILE. TEMP.OUT
      is a sequential file.

      The /ERROR qualifier specifies that if any error occurs while
      opening the file, the command interpreter should transfer
      control to the line at the label OPEN_ERROR. The command
      procedure writes records to the file TEMP.OUT until the symbol
      COUNT equals 11.

    3.$ OPEN/READ INPUT_FILE TRNTO::DKA0:[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 (EOF). At this point, the CLOSE command closes
      the file and deassigns the logical name INPUT_FILE.
Close Help