The ENDFILE statement will write an end-of-file record to the next record in an external file connected for sequential access. This record then becomes the last record in the file.
Like other I/O statements, the endfile statement supports several different specifiers. A complete list of the valid specifiers for the endfile record are as follows:
Unit= tells the computer in which file you want to place the end-of-file record. This or just the unit integer value by itself is the only required specifier with the ENDFILE statement.
This specifier is used to give information on the status of the operation. The integer value, that is stored in the integer variable placed after the equals sign, indicates whether the endfile operation went smoothly or not. A value of zero will indicate that no error occurred while executing the endfile command. However, if a positive value is stored in the integer variable, that means an error occurred while trying to execute the ENDFILE command. The exact meaning behind any one positive value is machine dependent. That means to find out the problem you will have to consult the FORTRAN manual on your specific system.
This specifier gives the statement label to which the program should branch in case an error occurred while trying to execute the endfile command.
There really aren't too many rules that govern the use of this command. Just keep in mind two things. First, remember how control is transferred in the program if an error occurs when the iostat and err specifiers are present. Second, only use this statement when you are finished writing to a file. Otherwise, any record that you write to a file after the end-of-file record has been added will be lost to any future use because the computer will never read beyond the end-of-file record. This is why many programmers are satisfied to use the end-of-file record that gets added to a file when the close command is issued. ENDFILE is largely a leftover from the days of extensive use of tape drives for data storage. If you do use this command it should take the following form.
or with the addition of specifiers:
lecture twenty two
Written by Jason Wehr : email@example.com and Maintained by John Mahaffy : firstname.lastname@example.org