Part One of a powerful filing program by Peter Patton
Microfile is a data filing program for the CPC464, which will allow you to create data files with up to IS fields of 50 characters, which is more than sufficient for most home and small business applications. The program will prompt you every step of the way, but the following points should be considered carefully.
Cassette data files are slow and cumbersome things to use, and for this reason the program holds it entire data file in memory. Data is stored dynamically, that is without waste, so although you may set up a data file in which records can hold up to 750 characters, only the actual characters entered into such records are placed in the file and the unused portion at the end of a data field are ignored.
Each time a data file is loaded into memory, a routine within the program checks to see how much memory space remains, and allocates the correct number of free records available for the current working session.
In order to reclaim the free space it is necessary to Save the data file, and then re-Load it. This means that if you start a session you may have, for example, room for 100 new records. If you were to enter 20 new records the free record counter would tell you that you have space for 80 more records. However, if you Save the file and xe-Load it again, then the free record counter may tell you that you now have space for 95 records. This does not mean that 15 records have been lost, it merely indicates that that much free space has been reclaimed. In this way it is not inconceivable that your files may exceed 1000 data records, all of which are held in memory at the same time.
When deciding how your data file is to be structured, you should first sit down with pen and paper, and decide what sections or fields your data can be broken down to, and how many characters the largest single data item will take. In this way you will find that your files are laid out in the way which optimises the storage method outlined above. For example, if you wish to create a file which will hold names and addresses, you may decide that you need these data fields:
- First names
- Post Code
Having decided that these are the fields you wish to create, you must then allocate space to store this information. If we take field one Surname as an example, it would be all right to allocate 10 characters to this field, if you could be certain that all Surnames to be entered here would be 10 characters or less. However, if you have to enter the name Higginbottom, you will end up with the name Higginbott. This is because you failed to make allowances for such an eventuality when you created the file.
Similarly, if you think you'll play it safe and make the fields all of the maximum 50 characters, you will reduce your initial file capacity to some 47 records, thus you will spend much unnecessary time Saving and re-Loading the file in order to create more free records. So you can see that five minutes with pen and paper, can save many hours of frustration later. A typical example of the same file, structured with care may be:
- Surname (20 characters)
- first names (23 characters)
- Address (40 characters)
- Town (20 characters)
- County (15 characters)
- Post Code (10 characters)
- Telephone (12 characters)
Such a file will now hold over 200 records at the outset, and may well expand to over 400 records, all of which are held in memory and thus are immediately accessible.
Some programmers like to be able to press a single key in answer to a program prompt. Which is fine if the person using the program presses the correct key. My own personal view is that people often press wrong keys, and so you will find that all inputs in this program require you to press Enter before any action is taken. This causes little or no inconvenience, and at the same time allows you to change your mind if you select the wrong key.
If at any time you enter a wrong key, it may be cancelled by pressing the Del key. However, this is destructive,, and will erase any character it passes over, placing a star where the character was. The stars are not a part of the input, so don't worry if you leave them at the end of a data field. If you wish to carry on typing, they are simply typed over. An input ends wherever the cursor is when you press Enter.