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

279 OPENIN open file for input to computer (from cassette, disc or Econet) Purpose To tell the computer that the program wishes to read data (words and numbers). Reading data in is quite a complicated procedure for the computer and it needs advance warning when you wish to do so. The advance warning is given by the OPENIN keyword. One use of this facility is to store names and addresses on file (eg the cassette or disc) and to read the file in each time you want to use it. After you have corrected it you can then transfer it back to disc (using OPENOUT ) where it will be saved for future use. Further information about cassette, disc and Econet files is provided in chapter 31.

A typical example of the use of OPENIN is X=OPENIN("cinemas") This informs the computer that you will shortly want to read data in from a file which is recorded under the name ‘cinemas’. The file name is ‘cinemas’. In accepting this instruction the computer allocates a ‘channel’ to this operation. It is as if it said ‘OK that information will be provided on telephone number 6’. It makes X=6 (or whatever number it decides). In all future operations on that file you must refer to it as channel X (channel 6 in this example). You get the actual data into the computer by using either BGET#X or INPUT#X as the demonstration program on the next page indicates.

Example 230 file=OPENIN("census") Description A function which attempts to open a file for input or random access. In a disc or Econet environment if a file already exists with the correct name it will be opened for reading. The function returns the channel number allocated by the computer’s filing system. If the file does not exist then zero is returned.