Name
TextFile Type
Syntax
type TextFile;
Description
The TextFile type represents a text file. A text
file is different from a binary file in that a text file contains
lines of text, where the size of each line can vary. Unlike standard
Pascal, the TextFile type is unrelated to
File
of
Char.
The actual encoding of a line ending is not relevant in a Delphi
program. The ReadLn and WriteLn
procedures and the Eoln and
SeekEoln functions automatically handle line
endings. A text file ends at the end of the file or at the first
occurrence of the #26 character (Ctrl-Z).
Tips and Tricks
By default, text files are buffered with a 128-byte buffer. You can choose a different size buffer by calling
SetTextBuf.The
TextFiletype is equivalent to the following record. TheSysUtilsunit has a declaration of this type, or you can copy the declaration to your own unit.
type PTextBuf = ^TTextBuf; TTextBuf = array[0..127] of Char; TTextRec = packed record Handle: Integer; Mode: Integer; // fmInput or fmOutput BufSize: Cardinal; // Size of Buffer. BufPos: Cardinal; // Current position in Buffer. BufEnd: Cardinal; // Last position of data in Buffer. BufPtr: PChar; // Pointer to the start of the data in Buffer. OpenFunc: Pointer; // Pointers to functions that take a InOutFunc: Pointer; // var TextFile argument and return an FlushFunc: Pointer; // integer result: zero for success and an CloseFunc: Pointer; // error code for an error. UserData: array[1..32] of Byte; // For your use. Name: array[0..259] of Char; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access