Note:
For Win32 applications, text-oriented I/O is available only in console applications, that is, applications
compiled with the Generate console application option checked on the Linker page of the Project Options
dialog box or with the -cc command-line compiler option. In a GUI (non-console) application, any attempt to
read or write using Input or Output will produce an I/O error.
Some of the standard I/O routines that work on text files don't need to have a file variable explicitly given as a
parameter. If the file parameter is omitted, Input or Output is assumed by default, depending on whether the
procedure or function is input- or output-oriented. For example, Read(X) corresponds to Read(Input, X) and Write
(X) corresponds to Write(Output, X).
If you do specify a file when calling one of the input or output routines that work on text files, the file must be associated
with an external file using AssignFile, and opened using Reset, Rewrite, or Append. An error occurs if you pass a
file that was opened with Reset to an output-oriented procedure or function. An error also occurs if you pass a file
that was opened with Rewrite or Append to an input-oriented procedure or function.
Untyped Files
Untyped files are low-level I/O channels used primarily for direct access to disk files regardless of type and
structuring. An untyped file is declared with the word file and nothing more. For example,
var DataFile: file;
For untyped files, the Reset and Rewrite procedures allow an extra parameter to specify the record size used in data
transfers. For historical reasons, the default record size is 128 bytes. A record size of 1 is the only value that correctly
reflects the exact size of any file. (No partial records are possible when the record size is 1.)
Except for Read and Write, all typed-file standard procedures and functions are also allowed on untyped files. Instead
of Read and Write, two procedures called BlockRead and BlockWrite are used for high-speed data transfers.
Dostları ilə paylaş: