File variables are used to process files (i.e. create, destroy, change, or retrieve values from files). The term file is a shorthand way of saying collection of values defined by a file type.
The following built-in functions and procedures operate on file variables:
The simple example program below uses a file variable (f) to create a file called numbers.dat and write the numbers 1 to 10 to the file.
program numbers; var f : file of integer; i : integer; begin assign(f, 'numbers.dat'); rewrite(f); for i := 1 to 10 do write(f, i); end.
The syntax for referencing file variables is given below:
(NOTE: for clarity some parts of the syntax are omitted, see Irie Pascal Grammar for the full syntax):
file-variable = variable-access