file-type-definition : FILE OF type
file-name : expression(string)
file-declaration :
FILE simple-name ":" subtype IS [ mode ] file-name ";"
The subtype in the file declaration must be a file type. The mode of the file declaration must be IN or OUT indicating if the file can be read or written. If the mode is IN, then during execution the file with the specified file name will be opened for reading. This file must exist in the current directory and must have been written as a file of the same type. If the mode is OUT, then a file is created with the specified file name with the specified type.
If the file declaration appears within a subprogram, then that file is closed when the subprogram exits. Otherwise, it remains open until the end of execution. An object of the file type must be a variable.
The object declared by a file declaration may only be used as a parameter to the built-in read, write, and endfile subprograms. These subprograms are declared as follows
procedure read(f: in FT; value: out TM); procedure write(f: in FT; value: in TM); function endfile(f: in FT) return boolean;
A special package named textio, described in this chapter, provides input and output with text files and the screen and keyboard.