3.3.4 File types

File types are types that store a sequence of some base type, which can be any type except another file type. It can contain (in principle) an infinite number of elements. File types are used commonly to store data on disk. However, nothing prevents the programmer, from writing a file driver that stores its data for instance in memory.

Here is the type declaration for a file type:

_________________________________________________________________________________________________________
File types

--file type -file--|------------------------------------------------
               -of- type--
___________________________________________________________________

If no type identifier is given, then the file is an untyped file; it can be considered as equivalent to a file of bytes. Untyped files require special commands to act on them (see Blockread, Blockwrite). The following declaration declares a file of records:

Type  
  Point = Record  
    X,Y,Z : real;  
    end;  
  PointFile = File of Point;

Internally, files are represented by the FileRec record, which is declared in the Dos or SysUtils units.

A special file type is the Text file type, represented by the TextRec record. A file of type Text uses special input-output routines. The default Input, Output and StdErr file types are defined in the system unit: they are all of type Text, and are opened by the system unit initialization code.