# Books, channels and files

In Algol 68 terms, external values are held in a book. Books have various properties. They usually have an identification string. Some books can be read, some written to and some permit both reading and writing. Some books allow you to browse: that is, they allow you to start anywhere and read (or write) from that point on. If browsing is allowed, you can restart at the beginning. Some books allow you to store external values in text form (human-readable form) only, while others allow you to store values in a compact internal form known as binary. In the latter form, values are stored more or less in the same form as they are held in the program. The values will not usually be human-readable, being more suited to fast access by computer programs.

In operating-system terms, Algol 68 books are called “files” (just to confuse you, of course), but a book has a wider meaning than an operating-system file.10.1 When reading external values from the keyboard, your program is reading data from a read-only book. When printing data, your program is writing data to a write-only book. When accessing a device, such as `/dev/ttyS2`, to which you can attach a modem, your program can both read from and write to the book, but it cannot browse in it.

The data (as external values are called) in a book, or the data to be put in a book, travels between the book and your program via a channel. Three principal channels are provided in the standard prelude: `stand in channel`, `stand out channel` and `stand back channel`. The first is used for books which can only be read (they are “read-only”), the second for books which can only be written to (they are “write-only”) and the last for books which permit both reading and writing. This classification is a little over-simplified. Many books permit both reading and writing, but you may only want your program to read it. The three standard channels mentioned are all “buffered”. This means that when you, for example, write data to a book, the data is collected in memory until a fixed amount has been transput, when the collection is written to the book in its entirety. The standard channels use a buffer of 4096 bytes. The mode of a channel is `CHANNEL` and is declared in the standard prelude.

Your program keeps track of where you are in a book, which book is being accessed and whether you have come to the end of the book by means of a special structure which has the mode `FILE`. This is a complicated structure declared in the standard prelude. The internals of values of mode `FILE` are likely to change from time to time, but the methods of using them will remain the same.