|
VMS Help WRITE, Examples *Conan The Librarian |
1.$ WRITE SYS$OUTPUT "Beginning second phase of tests"
The WRITE command writes a single line of text to the current
output device.
2.$ OPEN/APPEND OUTPUT_FILE TRNTO::DKA1:[PGM]PLAN.DAT
$ WRITE OUTPUT_FILE "BEGINNING PHASE 3"
In this example, the OPEN/APPEND command opens the file
PLAN.DAT at the remote node TRNTO and positions the pointer
at the end of the file. The WRITE command writes a record to
the end of the file PLAN.DAT.
3.$ OPEN/WRITE OUTPUT_FILE TESTFILE.DAT
$ INQUIRE ID "Assign Test-id Number"
$ WRITE/ERROR=WRITE_ERROR OUTPUT_FILE "Test-id is ",ID
$ WRITE/ERROR=WRITE_ERROR OUTPUT_FILE ""
$ !
$ WRITE_LOOP:
.
.
.
$ GOTO WRITE_LOOP
$ END_LOOP:
$ !
$ CLOSE OUTPUT_FILE
$ PRINT TESTFILE.DAT
$ EXIT
$ !
$ WRITE_ERROR:
$ WRITE SYS$OUTPUT "There was a WRITE error."
$ CLOSE OUTPUT_FILE
$ EXIT
In this example, the OPEN command opens the file TESTFILE.DAT;
the INQUIRE command requests an identification number to be
assigned to a particular run of the procedure. The number
entered is equated to the symbol ID. The WRITE commands write
a text line concatenated with the symbol name ID and a blank
line.
The lines between the label WRITE_LOOP and END_LOOP process
information and write additional data to the file. When the
processing is finished, control is transferred to the label
END_LOOP. The CLOSE and PRINT commands at this label close the
output file and queue a copy of the file to the system printer.
The label WRITE_ERROR is used as the target of the /ERROR
qualifier to the WRITE command; if an error occurs when a
record is being written, control is transferred to the label
WRITE_ERROR.
4.$ OPEN/APPEND MYFILE [LAMPERT]TESTING.DAT
$ WRITE/SYMBOL MYFILE A,B,C
This example assumes that the symbols A, B, and C have
already been defined. The OPEN/APPEND command opens the file
[LAMPERT]TESTING.DAT and positions the pointer at the end of
the file. The WRITE/SYMBOL command concatenates the values of
the symbols A, B, and C and writes this data to a new record at
the end of the file.
|
|