COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-296
WRITE for Sequential Files
In the CRE, the logical record is always transmitted to the file or spooler buffer
immediately.
•
Opening File Positions Printer at Top of First Page
When you open a file, the printer is positioned at the top of the first page, as if
BEFORE ADVANCING PAGE had been executed. If you use default advancing
(AFTER ADVANCING 1), you get a blank line at the top of the first page. (You
usually use BEFORE 1 before the first write operation.)
•
Files That Are Not Printers or Spooler Files
If a file is not a printer or spooler file, each logical record is written to the file
immediately, any ADVANCING clause is ignored, and no control information (for
advancing or forms control) or extra blank lines are written to the file.
•
Writing to EDIT Files
An HP COBOL program can write at most 239 characters to an EDIT file (a file
with file code 101). The action of the WRITE statement depends on the existence
of the file and on the form of OPEN used.
°
Existing EDIT file, OPEN EXTEND
Each write operation appends a line to the file. The line numbers of the new
lines begin at a value one greater than the last line number in the file, and are
incremented by one.
°
Existing EDIT file, OPEN OUTPUT
Existing records are deleted from the file. Each write operation appends a line
to the file. Line numbers begin at one and are incremented by one.
°
File does not exist, OPEN OUTPUT or EXTEND
For the write operation to create the file, the run-time environment must contain
an ASSIGN command that specifies CODE 101. Each write operation appends
a line to the file. Line numbers begin at one and are incremented by one.
To make the file an EDIT file before writing it, use the COBOL_ASSIGN_
routine with file-code 101.
°
Program was compiled with the NONSTOP directive
If a program was compiled with the NONSTOP directive, it can open an EDIT
file for input, but not for either form of output.
•
File-Status Data Item
If the file has an associated file-status data item, execution of the WRITE
statement always assigns an appropriate I-O status code. The value “00” reports a
successful write operation.