System information
0254 6572726F72errmsg: db 'error, try again.$'
0266 6E65787420prompt: db 'next command? $'
;
; fixed and variable data area
;
0275 21 conbuf: db conlen ; length of console buffer
0276 consiz: ds 1 ; resulting size after read
0277 conlin: ds 32 ; length 32 buffer
0021 = conlen equ $-consiz
;
0297 ds 32
stack:
02B7 end
Major improvements could be made to this particular program to enhance its operation. In fact,
with some work, this program could evolve into a simple data base management system. One
could, for example, assume a standard record size of 128 bytes, consisting to arbitrary fields
within the record. A program, called GETKEY, could be developed that first reads a sequential
file and extracts a specific field defined by the operator. For example, the command
GETKEY NAMES.DAT LASTNAME 10 20
would cause GETKEY to read the data base file NAMES.DAT and extract the LASTNAME
field from each record, starting in position 10 and ending at character 20. GETKEY builds a table
in memory consisting of each particular LASTNAME field, along with its 16-bit record number
location within the file. The GETKEY program then sorts this list and writes a new file, called
LASTNAME.KEY, which is an alphabetical list of LASTNAME fields with their corresponding
record numbers. This list is called an inverted index in information retrieval parlance.
If the programmer were to rename the program shown above as QUERY and modify it so that it
reads a sorted key file into memory, the command line might appear as
QUERY NAMES.DAT LASTNAME.KEY
5.5 A Sample Random Access Program CP/M Operating System Manual
5-53