## 9.B. Textfiles 

Textfiles are files that consist of a sequence of characters that is subdivided into variable-length tOICS. The predefined type Text is used to declare textfiles. 

We may consider the type Text as being defined over the base type Char extended by a (hypothetical) line terminator or end-of-line marker. Therefore type Text is nut equivalent to (Packed) file of Char. This end-of-line marker can be both recognized and generated by the following special textfile procedures. 

Writeln (F) terminates the current line of the textfile F. 

Readln (F) skips to the beginning of the next line of the textfile F (Fi becomes the fiN character of the next line). 

Eoln (F) a Boolean function mdicating whether the end of the current line in the te '(tfile F has been reached. (If true, Fi corresponds to the position of a line separator, but Fi is a blank.) 

If F is a textfile and Ch a character variable, 

Write (F, Ch) is an abbreviation for begin Fi : = Ch; E .. t (F) end 

Read (F, Ch) assigns the character iat the current position of file F or the value of Fi to Ch, followed by a Get (F) . The choice is implement;ltion-dependent. 

Input and Output are the names of two standard textfile variables used as program parameters for le;!ible reading and writing of text. Chapter 12 describes them in detail t, 'gether with extended forms ofthe procedures P.ead, Write, Readln, ani ',~citeln. 

The following program schem; ta use the above conventions to demonstrate some typical operation. performed on textfiles. 

1. Writing a textfile Y. Assume that (") computes a (next) character and assigns it to parameter c. If the .:lIlTcnt line is to be terminated, a Boolean variable Bl is set to true; and if the text is to be terminated, B2 is set to true. 

