Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF (EN)

163 31 File handling You are probably already aware that as well as storing computer programs on cassette or disc, you can store ‘data’. By ‘data’ we mean sets of numbers or words. We might, for example, store a set of names and telephone numbers. This set of data is called a file. A set of BASIC statements are provided to enable you to read information from files, to write information to a new file, to update an existing file, to delete a file, to find out how big a file is, to move to a certain record in a file, to check if you have reached the end of a file and to obtain a catalogue of all the files that exist.

There are also several other statements for performing other actions on the files. One of the major features of the BBC Microcomputer system is that exactly the same statements are used no matter which ‘filing system’ is in use. A number of different filing systems are available including cassette, disc and Econet systems. Programs written to work on a cassette filing system will usually work unmodified on a disc system. See chapter 36 for details of other filing systems. First here is a summary of all the file handling statements available in BBC BASIC. *CAT Gives a catalogue of all data files and programs on the cassette or floppy disc. It takes a very long time on a cassette.

OPENIN Opens a file so that it can be read. OPENOUT Opens a new (empty) file for writing. OPENUP Opens a file for reading and/or writing. (Not cassette.) INPUT# Reads data from a file into the computer. PRINT# Writes data from the computer into a file. BGET# Reads a single character (byte) from a file. BPUT# Writes a single character (byte) to a file. PTR# Can be used either to find out which record we are about to read (or write) or to move to a specific record. (Not cassette.) EXT# Indicates how long a file is. (Not cassette.) EOF# Indicates whether or not the end of a file has been reached. CLOSE# Indicates to the computer that you have finished with a file.