User`s guide

Prompt:
02D1 6E65787420 db 'next command? $'
entmsg :
02E0 656E746572 db 'enter filename: $'
;******************************
;* *
;* fixed and variable data area *
;* *
;******************************
02F1 21 conbuf: db conlen ;length of console buffer
02F2 consiz: ds 1 ;resulting size after read
02F3 conlin: ds 32 ;length 32 buffer
0021 = conlen equ $-consiz
pfncb :
0313 F302 dW conlin
0315 5C00 dw fcb
0317 ds 32 ;i16 level Stack
stack :
0337 end
You could make the following major improvements to this program to enhance its
operation. With some work, this program could evolve into a simple data base
management system. You could, for example, assume a standard record size of 128
bytes, consisting of arbitrary fields within the record. You could develop a program
called GETKEY 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 at position 10 and ending at charac-
ter 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. This list,
sometimes called an inverted index, is an alphabetical list of LASTNAME fields with
their corresponding record numbers.
You could rename the program shown above to 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
4-19
4.3 A Sample Random Access Program CP/M 3 Programmer's Guide