Database ======== 1. Introduction --------------- This Cosma database program for the BBC Micro will run on either the Model A or Model B machines, although obviously the amount of data that can be held depends upon the memory size of the machine. There is a maximum of 100 records on a 16K machine, and 255 records on a 32K machine. You may keep as many data files as you wish, but only one at a time may be loaded into the computer. Please note that data files can be stored at either 300 or 1200 baud (slow or fast storage) although 1200 baud is far quicker and more convenient, it is less reliable, and in fact will not work at all on micros with version 0.1 of the Operating System. In general, if an error message is displayed for an illegal entry, it will be displayed for a set length of time, but pressing any key will cause it to be removed instantly, so that the programme can continue. First of all, it may help to explain some of the terms used for the database. We shall compare the database with a manual card indexing system, with cards for, say, a stamp collection held in a box, with a different card for each stamp. File This is the same as a complete box. It is held on cassette tape, and you can have as many files as you wish, but only one may be loaded into the computer memory for manipulation at any one time. Record A record is the same as one of the cards in our card indexing system. A file therefore consists of a number of records. Field A card may contain a number of headings that you wish to regard as being separated entities e.g. Type, County, Value etc. In the database system, you may have up to 15 fields. 2. The Programme Intro ---------------------- This is the programme which will set up a datafile for you. It is necessary to define how many fields you want in each record of the data file, what the field title is, how long it is, and what type it is (String or Numeric). A String field may contain any characters, but a numeric may hold only digits, and can be used for calculations in the main programme. Not that the more fields you wish to hold, the more memory space they will use up e.g. an address held as 1 field of 60 characters takes up less memory than an address held as three fields of 20 characters each. Load and run in the usual way with the commands LOAD"" and RUN, or with the command CHAIN"". Then take the following steps: 1. Enter the number of fields that you will require (a field is a heading within the record that you wish to regard as a separate entity, e.g. Name, Age, Title, etc) 2. For each of the fields, type the field name, its length, and whether it is to be numeric, or a string (just press the N or S keys, do not press RETURN afterwards). 3. Confirm whether the fields as they are now displayed are correct - if not, you will be taken to the beginning of the programme (press Y or N). 4. Save the datafile onto a blank cassette tape as required (The datafile is stored at 300 baud). 5. Place the main programme cassette in the tape recorder, rewound on the main programme side (DATABASE), and the main programme will now be loaded and run automatically. 3. Main Programme: Database --------------------------- This programme will first load up the datafile that you wish to use. Press S for slow (300) cassette speed, and F for fast (1200) cassette speed. If the file is either a new one created by INTRO, or the demonstration file, or a file which was saved previously by the main programme using the slow cassette option, then press S. you are now taken to the Main Menu, which has a total of 11 options, as follows: 3.1 Option A: Add Records To The File ------------------------------------- This places another complete database record on the file in the computer memory. For each field, enter the information, followed by the RETURN key. After entering the line of the last field for the record, press either Y or N to the prompt, "Is this correct?" and you can then enter another record. If you do not wish to enter any more records, type * followed by the RETURN key for the first field of the record. 3.2 Option B: Bytes Free ------------------------ This option is included for your own use to ensure that you do not run out of memory space. The programme will not allow you to enter a new record by using option A when there is insufficient memory space. The figures given are the number of bytes (single characters) free, and the approximate number of records that can be stored in total. This last figure is based on the average length of records already entered on the file. 3.3. Option C: Calculations --------------------------- This powerful facility enables you to perform various calculations on any of the numeric fields in your records. First, you will be asked whether you wish to Total (press T0, or Update (press U). The choice for (T)otal, will total the values for a given field for the entire file. The choice (U)pdate allows you to take any numeric field, perform any calculation on it, and put the result in any numeric field. This can be done for any range of records within the file (e.g. from records 4 to 12). Thus you could for instance, take field 5 (for price), multiply it by 1.15, and put the result in field 6 (for VAT inclusive price). Once the two fields that you wish to use have been entered, then the formula that will calculate the new values can be typed in. The field which is to be used for the calculation is represented by a capital F, so if, for example, you wish to multiply it by 4, and add 100, then the formula will be F*4+100. Note that where the F comes in the formula is irrelevant, and so 100+F*4 will do just as well. The normal rules of algebra apply, so that F-100*4 will in fact subtract 400 from the field - the multiplication sign (*) takes priority over subtraction (-). Any of the built-in fucntions of the BBC can be used (e.g. SIN, EXP, etc) - for a full description of these functions, please refer to the BBC manual. The operators that you are most likely to want to use, are * (multiply), + (add), / (divide) and - (subtract). 3.4. Option D: Delete A Record ------------------------------ Enter the record number followed by the RETURN key. Then at the prompt "Please confirm to delete", press either Y or N. A record once deleted, cannot be retrieved. 3.5. Option E: Exit Programme ----------------------------- The first asks you whether you wish to save the data in memory onto a cassette tape (this is because once the programme terminates, the data will be lost). If yes (press Y), the 'Save file on tape' routine will be entered, before leaving the programme. 3.6. Option F: Find Record -------------------------- If you wish to find a record or a number of records, but do not know their record numbers, then apart from listing the entire file for the records that you require, you can use this option. You can search for and list all records that satisfy up to eight selection criteria, which must be specified as follows: a) Nominate the field to be checked. b) Enter the minimum and maximum values (e.g. 100,200 for a numeric field means all records with values from 100 to 200 in that field, and A,M for a string field means all records alphabetically from A to M in that field). c) Now specify the next selection as above. If you have entered all the criteria, enter 0 for the field number. Once all the criteria have been entered, the programme will search for, and list all the records which satisfy all the criteria. Example: Selection 1 - field 1, values. SMITH, SMITH. Selection 2 - field 5 values. 1000,2000. Selection 3 - enter 0 for the field. This will now search the file for all records which have the name SMITH in field 1, AND have a value from 1000 to 2000 in field 5. 3.7. Option L: List Records --------------------------- Enter the numbers of the first and last records to be listed, and these records will now be displayed in full, one by one. If you wish to advance quickly through the records press any key, and hold it down. 3.8. Option M: Modify Record ---------------------------- Enter the number of the record that you wish to modify. You can now either change any of the lines in the record by typing the new line followed by the RETURN key, or keep the line as it is listed, by just pressing RETURN. You may use the DELETE key to delete the last character on a line that you have entered. 3.9. Option P: Print File ------------------------- Exactly as for option L, but prints the record on the printer. 3.10. Option S: Sort File ------------------------- Using this option, the entire file can be sorted in either ascending or descending order on any field. A different sort is automatically performed on the field, depending on whether it is numeric or string, so that a string field is in alphabetical order, and a numeric field is in numerical order. Please note that this may take some time, if there are a large number of records on the file. 3.11. Option W: Write File -------------------------- This option will save all the information that you have entered into the file, or any records that you may have changed, onto a cassette tape. Enter either S or F for slow or fast cassette transfer speeds. A file does not have to be saved at the same speed that it was loaded at. Loading ------- Tape: CHAIN"" (RETURN) Disc: SHIFT-BREAK