Pecamj

January, 1984 87

DSRS Data Storage and Retrieval System

An in-memory data management program

DSRS is a data storage and retrieval system designed for a TRS-80 Model I disk system, with either 32K or 48K of memory. The program (Listing 1) is intended for home record keeping purposes such as mailing addresses, telephone numbers, lists of books, collections and similar lists. The program utilizes sequential disk-access techniques and the data file is limited in size by the amount of available memory. With 48K of memory, data files of about 25K bytes may be handled, which is more than sufficient for most household purposes. Should a file grow too large, the program has several provisions for creating several files from the original.

The typical home computer user does not really need the size and power of a large, expensive data base system which is intended for business users. Since such systems usually work with individual disk entries, a lot of disk access is typically necessary for even simple operations. The big advantage of the DSRS program is that the entire file is loaded into memory once and remains resident until the user loads another data file. This memory-resident data file results in faster operation than systems which rely on disk-resident data files. Time requirements for search and sort operations are especially improved over random-access disk file techniqxies.

DSRS is easy to use and all commands are menu selections. The user is prompted for all required information and data entries. Command selections are available to provide numerous options for data retrieval, searching, sorting and printing. Each data file is configured at the time of creation, so the user is riot locked into a particular number of data fields. Each data entry consists of a number of named fields such as name, address, or phone number, which are defined by the user. In accordance with standard BASIC characteristics, up to 240 bytes may be typed in for each of the fields of data entry. The use of the lineinput command allows the user to include normal punctuation within the line.

File Creation (Command 2)

After typing in DSRS and running the program, you will be presented with a command menu consisting of 13 different commands. The first command you will need to use will be the "create data file" command, which is selection number two of the command menu. Upon selection, you will be asked to supply a name for the data file (not a filespec), the maximum number of items to be entered in the file, and the number of fields (lines) to be supplied for each item to be entered in the file.

Gary Small, Scarborough, ME

As a matter of practice, the number of entries should be made as high as possible, consistent with memory size and the number of fields for each entry. The maximum number you may use is a function of the algorithm used by BASIC in order to allocate memory space. Table 1 presents typical limits for a 48K system.

Table 1

Data File Size Limitations

100 18

350 4

425 3

500 2

700 1

Should you enter numbers which exceed the limits imposed by BASIC, an error message will be generated. Due to an apparent design problem in BASIC, the dimensioning limits of string variables is based on non-string memory. Thus, the program is not able to use all of the computer's memory for string storage. Some amount of non-string memory must be left unreserved to allow the dimensioning of reasonably-sized data files, as shown in Table 1. You will also notice that the product of the number of entries multiplied by the number of fields diminishes rapidly as the number of entries grows. Thus, 1800 lines can be entered into a 100-item file, while only 700 lines can be entered into a 700-item file.

Once you have set up the number of entries and fields, the program will prompt you to enter a name for each field. As an example, you might set up a file to store the title, author and subject of a collection of books. Table 1 indicates you could set up a file of 425 entries with three fields per entry. The fields would then be named title, author and subject.

Once the fields have been named, the program will proceed with the data entry sequence, prompting the user to enter a line of data for each field of each entry. While in this mode, the uparrow key may be used to back up to the previous line of entry in order to correct mistakes. The data entry sequence may be terminated either by filling up the file with data, or by pressing enter in response to the prompt for the first field entry of any item. At termination, the user is prompted to save the file and must supply a filespec name for the disk file.

Modifying the Data File

Three commands are provided for modifying the contents of a data file. These commands allow the user to add entries to the file, delete entries from the file, and modify the contents of any entry. The addition and modification commands prompt the user for all information required by the command. They use the same data entry sequence as was described in the create file command. In order to modify or delete a data file entry, it is necessary to know the data item entry number. This number is easily found by using the listing command described later. It should be noted that a data file must be resident in memory before any of the file modification, search, sort or print commands may be used. Thus, a create file or load file command must be the first command used in any given work session.

Searching and Sorting

Three DSRS commands provide the facility to perform alphanumeric sorts, global searches and limited searches on the data file information. Each of these operations provides the option of saving the results of the operation to a new disk file. This makes it relatively easy to expand an overcrowded file into multiple files, utilizing appropriately-selected categories of search. Options to print the results on either the CRT or the lineprinter are also included.

The sort command will perform an alphanumeric sort of the entire data file. The user is prompted to select a field to govern the sort. Using our previous example of title, author and subject as fields, it would be very easy to perform three sorts of the data and end up with separate files organized by title, author and subject.

Two search commands provide the user with the capability of flagging all data entries which contain information that matches a user-supplied keyword or sentence. The "search entire file" command will search every field of every entry for a match to the keyword. The "search single field" command limits the search to a single field, selected by the user, of each data entry, thus limiting the responses. In either case, the option is provided to print the results to either the video or the lineprinter. The option of saving a new data file consisting of only those items flagged by the search is also provided.

Printouts

DSRS offers a number of different options for producing printouts of file data. All commands provide the capability of sending the output to either the video or the lineprinter. The user can elect to printout the entire data file if desired. The user also has the option of printing out a single field from each data entry. A good example of this command would be to generate a list of titles from the example data file we have been using.

The third printout command is a powerful command which allows the user to custom-configure the printout, including selection of fields to be printed, width of printout, and lines between fields. This command is

Get more use from your Model 100 Let the Elves help!

ELF 1 +1 CALCULATOR

Why carry your computer and calculator? ELF 1 + 1 turns your computer into an easy to use calculator. Features: Entry, Total & Memory displays; % key; Auto-Constant; + More!

0 0

Post a comment