Appending to a File

Product Version(s): 3.x 4.00 4.01
Operating System:   MS-DOS
Flags: ENDUSER |
Last Modified:  8-MAR-1988    ArticleIdent: Q11271

Problem:
   Under mainframe FORTRAN there is a function MOD; it adds data to
the end of a file in FORTRAN. I cannot find a similar
command in your compiler. I want to add some data to
the end of an ASCII file.
   I have used the command ENDFILE as an example to solve the problem.
However, a sequential file that is opened and written to will
overwrite the existing data (as stated in the manual).

Response:
   On Pages 15-23 and 15-23s of the ANSI FORTRAN standard (ANSI
X3.9-1978, which both mainframe and microcomputers follow), in the
section concerning functions and subroutines, a MOD function is
described that is used for remaindering, not for appending data to a
file.
   The only function we are aware of that you may be thinking of is
the specifier that some FORTRANs have added to the OPEN statement for
example, ACCESS=APPEND. However, this is not part of the ANSI
standard.
   At any rate, there is no mechanism in the ANSI standard to append
to the end of files, and we have not added one. The only way to append
to the end of a file is to do the following:

   1. Read from an old file.
   2. Write to a new file.
   3. Repeat (1) and (2) until reaching end-of file on the old file.
   4. Write new information to the new file.