Writeln
Does the same as Write, and then writes an end-of-line marker to the text file.
A file variable is any variable whose type is a file type. There are three classes of file: typed, text, and untyped. The
syntax for declaring file types is given in File types.
Before a file variable can be used, it must be associated with an external file through a call to the AssignFile
procedure. An external file is typically a named disk file, but it can also be a device, such as the keyboard or the
display. The external file stores the information written to the file or supplies the information read from the file.
Once the association with an external file is established, the file variable must be
opened to prepare it for input or
output. An existing file can be opened via the Reset procedure, and a new file can be created and opened via the
Rewrite procedure. Text files opened with Reset are read-only and text files opened with Rewrite and Append are
write-only. Typed files and untyped files always allow both reading and writing regardless of whether they were
opened with Reset or Rewrite.
Every file is a linear sequence of components, each of which has the component type (or record type) of the file.
The components are numbered starting with zero.
Files are normally accessed sequentially. That is, when a component is read using the standard procedure Read or
written using the standard procedure Write, the current file position moves to the next numerically ordered file
component. Typed files and untyped files can also be accessed randomly through the standard procedure Seek,
which moves the current file position to a specified component. The standard functions FilePos and FileSize can be
used to determine the current file position and the current file size.
When a program completes processing a file, the file must be closed using the standard procedure CloseFile. After
a file is closed, its associated external file is updated. The file variable can then be associated with another external
file.
By default, all calls to standard I/O procedures and functions are automatically checked for errors, and if an error
occurs an exception is raised (or the program is terminated if exception handling is not enabled). This automatic
checking can be turned on and off using the
{$I+} and
{$I} compiler directives. When I/O checking is off, that is,
when a procedure or function call is compiled in the
{$I} state an I/O error doesn't cause an exception to be raised;
to check the result of an I/O operation, you must call the standard function IOResult instead.
You must call the IOResult function to clear an error, even if you aren't interested in the error. If you don't clear an
error and
{$I+} is the current state, the next I/O function call will fail with the lingering IOResult error.
Dostları ilə paylaş: