JULY 14, 2011 - RANDOM OR SEQUENTIAL
As you might imagine, I have not found much time for working on my entry lately. However, things are improving and whilst the wife and little one are napping, I've gotten some work done.
I got my menu screen working, so I can choose which function I want to do (Create, modify, delete, print, etc.). I am now focusing on how I want to store my recipes on disk. DOS offers the ability to save your data in one of two text formats: either sequentially read or randomly accessed. Both have their advantages and disadvantages, and both have limitations.
With a sequential-access file, data is stored in fields that are separated by either commas or carriage returns. Data is written to the file in the same way that data is sent to the printer: you tell DOS that your target is the file, then when something is printed on the screen, it is also written to the file. Thus:
These would create two fields in the file. They are later retrieved thusly:
That is why they are sequential files: they are written and read sequentially. However, you can specify how many fields to skip before reading begins. This is relative to the position you are at. It only works in one direction though, so if you wish to go back a record, I believe you would have to close and re-open the file then jump to that field.
Another downside is that fields can be modified, but their replacement has to be the same number of characters. If it is fewer, a new field is corrected, and if it is longer, it overwrites the beginning of the next field.
The random access files are a little more handy in that they can be accessed in any order. Call up record 23 and either write to it or read from it. The downside to the random files is that you must specify the total number of characters each record will contain, and all records must be the same. This isn't a huge deal for most of my program, except for the tasting notes, etc. I can leave a generous amount of space for notes, but that limits how many records I can store on a disk.
I think I am going to have to go with the random access file, as it better fits the function I would like to have in my program. Maybe instead of having a field for entering sentences, I will instead have "Good?" "Brew Again?" and "Modify?" fields with Y and N responses. Something to think about...
Other than that, my only obstacle is a finnicky keyboard. Today the 6 key decided to quit working for a while. The G works most of the time, and the C either works, doesn't work, or works but repeats itself a few times. Also I turned the caps off and on again, and it would not actually write capitals until I cycled the power on the machine. It is a 28 year old machine.
Hopefully I can find some more time soon.