Nascom Newsletter |
Volume 3 · Number 3 · August 1983 |
| Page 33 of 37 |
|---|
end-of-record marker delimits data items it is not essential that
the records are of fixed length. Therefore it is impossible to
replace an item in the middle of a file directly – there is no
certainty where the record concerned begins,
Sequential files are quite convenient when you wish to read all the contents of a file into memory and carry out the manipulation of the data in memory. When you have finished processing the data in memory the entire data can be written to a sequential file. Thus in handling data which can be loaded into memory this is a convenient method to use, since operating on the data in memory is inevitably quicker than any method which requires repeated disc access to obtain individual data items. Small data files and index files can conveniently be treated in this way.
A random file can be read/
120 DOKE 3365,10
Since you have direct access in this way to any point in a file it is very simple to amend a specific record simply by rewriting the appropriate sector of data on disc. You can if necessary arrange your own ‘housekeeping’ routines to pack two sets of data into a sector, or to use 2 sectors to store each set of data. For example in the latter case you would access the 10’th item of the data by starting to read at relative sector 18 of the file (the first item is in sectors 0 and 1, the second in 2 and 3 etc).
The problem with a random file is knowing where to store a new
item of data, and more importantly where to find a data item.
Most records stored on disc will have the most important item in
the record at the beginning. The individual items of data in a
record are usually known as fields, and the first of these, or
the one by which each record is usually referenced (eg in
searches
| Page 33 of 37 |
|---|