|
VMS Help READ, Examples *Conan The Librarian |
1.$ OPEN IN NAMES.DAT
$ LOOP:
$ READ/END_OF_FILE=ENDIT IN NAME
.
.
.
$ GOTO LOOP
$ ENDIT:
$ CLOSE IN
The OPEN command opens the file NAMES.DAT for input and assigns
it the logical name of IN. The READ command reads records from
the file IN and places the contents into the symbol NAME. The
READ command specifies the label ENDIT to receive control when
the last record in the file has been read. The procedure loops
until all records in the file have been processed.
2.$ READ/ERROR=READERR/END_OF_FILE=OKAY MSGFILE CODE
.
.
.
$ READERR:
$ CLOSE MSGFILE
.
.
.
$ OKAY:
$ CLOSE MSGFILE
$ EXIT
The READ command reads records from the file MSGFILE and
places the contents into the symbol CODE. The READ command
also uses the /ERROR and /END_OF_FILE qualifiers to specify
labels to receive control at the end-of-file (EOF) and on
error conditions. At the EOF, control is transferred to the
label OKAY. On other read errors, control is transferred to the
READERR label.
3.$ READ SYS$COMMAND DATA_LINE
$ WRITE OUTPUT_FILE DATA_LINE
.
.
.
The READ command requests data from the current SYS$COMMAND
device. If the command procedure containing these lines is
executed interactively, the command issues a prompt to the
terminal, accepts a line of data, and equates the data entered
to the symbol name DATA_LINE.
Then the WRITE command writes the value of the symbol DATA_LINE
to the file identified by the logical name OUTPUT_FILE.
4.$ OPEN/READ INPUT_FILE TRNTO::INVENTORY.DAT
$ OPEN/APPEND OUTPUT_FILE RECEIVE.DAT
$ READ INPUT_FILE DATA_LINE
$ WRITE OUTPUT_FILE DATA_LINE
The OPEN/READ command opens the file INVENTORY.DAT at the
remote node TRNTO for reading and assigns it the logical name
INPUT_FILE. The OPEN/APPEND command opens the file RECEIVE.DAT
in the current default directory. The READ command requests
data from the file INVENTORY.DAT at the remote node TRNTO. The
WRITE command writes the value of the symbol DATA_LINE to the
end of the local file RECEIVE.DAT.
|
|