VMS Help PASCAL, Input Output, Seq Access Output, REWRITE *Conan The Librarian (sorry for the slow response - running on an old VAX) |
The REWRITE procedure readies a file for output. Syntax: REWRITE( file_variable [[, file_name]] [[, ERROR := error-recovery]] ); The 'file_variable' is the name of the file variable associated with the output file. The 'file_name' is a string expression to be associated with the file_variable. Files opened with REWRITE and the 'file_name' stay resident on the disk after the program exits. However, if the file was opened with the OPEN procedure, the 'file_name' is ignored. The 'error-recovery' specifies the action to be taken if an error occurs during execution of the routine. By default, after the first error, the error message is printed and execution is stopped. The file can be in any mode before REWRITE is called to set the mode to generation. If the file variable has not been opened, REWRITE creates and opens it using the same defaults as the OPEN procedure. The REWRITE procedure truncates a file to length zero and sets EOF and UFB to TRUE. You can then write new components into the file with the PUT, WRITE, and WRITELN procedures (WRITELN is defined only for text files). After the file is open, successive calls to REWRITE truncate the existing file to a length of zero; they do not create new versions of the file. To update an existing file with sequential organization, you must either use the EXTEND procedure, use the TRUNCATE procedure, or copy the contents to another file, specifying new values for the components you need to update. When applied to a file with relative or indexed organization, REWRITE deletes the contents of the file and sets the file position to the beginning of an empty file. See the "Compaq Pascal Language Reference Manual" for a complete description of the REWRITE procedure.
|