3.4 File types

3.4.1 Definitions

file_type_definition ::=
    file of type_mark

3.4.2 Examples

TYPE string_file IS FILE OF string
TYPE natural_file IS FILE OF natural

Two file types string_file and natural_file are declared.
They are to contain elements of the type string and natural .

TYPE ft IS FILE OF tm ;

PROCEDURE
read (
      f     : IN   ft ;
      value  : OUT tm ;
      length : OUT natural ) ;
PROCEDURE write (
      f    : OUT ft ;
      value : IN   tm ) ;
FUNCTION endfile ( f : IN ft )
      RETURN boolean ;

A file type ft with elements of the type tm is declared.

In the procedure read the next value is
to be read from a file.

In the procedure write a value is to be

attached to a file.

The function endfile checks whether the end
of a file has been reached.