Dec 112017
 
A set of file indexing routines for QuickBasic.
File INDEX.ZIP from The Programmer’s Corner in
Category BASIC Language
A set of file indexing routines for QuickBasic.
File Name File Size Zip Size Zip Type
AEBITCLS.BAS 640 351 deflated
AEBITCRE.BAS 1792 776 deflated
AEBITCRQ.BAS 1247 589 deflated
AEBITFIN.BAS 1536 640 deflated
AEBITINS.BAS 2688 996 deflated
AEBITKIL.BAS 11726 2077 deflated
AEBITLFT.BAS 768 411 deflated
AEBITNEX.BAS 1435 596 deflated
AEBITOPE.BAS 1152 494 deflated
AEBITPRV.BAS 1168 490 deflated
AEBITRGT.BAS 768 410 deflated
AECOMMON.BAS 1024 496 deflated
AEGETFLS.BAS 1024 480 deflated
AEGETREC.BAS 2560 825 deflated
AEINITFL.BAS 1536 577 deflated
AEMRKCLS.BAS 1280 597 deflated
AEMRKOPE.BAS 1280 586 deflated
AERELREC.BAS 1408 599 deflated
AESHARED.BAS 384 163 deflated
IDXTEST4.BAS 4519 1269 deflated
NAMES.BAS 9171 2364 deflated
READ.ME 13824 3563 deflated
TPCREAD.ME 199 165 deflated

Download File INDEX.ZIP Here

Contents of the READ.ME file


This collection of QuickBASIC sub-programs is supplied 'as is'. I
guarantee nothing! I have tested these routines thoroughly and
they work - to the best of my knowledge. If you find a bug,
please let me know and I'll correct it as soon as possible.


Roy Barrow
222 Church Street
Philadelphia
PA 19106

BASIC Programmers Bulletin Board System (215) 627-3910

or you can call me on
(215) 922 2557



AEBITCLS - SUB PROGRAM

Close an index file. To close an index file, the number of that
index is passed to the routine. The index file proper is closed,
the header file is opened and the index data in memory is written
to the header / control file.

CALLING SEQUENCE & PARAMETER LIST

CALL bit.close(fl%)

WHERE

fl% is the file number of the index.



AEBITCRE - SUB PROGRAM

This routine asks the questions needed to created an index file.
This routine is supplied for interest only and is superseded by
AEBITCRQ. This will not be supported in future releases.

Questions:

name of header file
length of key

CALLING SEQUENCE & PARAMETER LIST

call bit.creat




AEBITCRQ - SUB PROGRAM

This routine is parameter driven, and serves only to create a NEW
index file. Existing files should be OPEN'ed with AEBITOPE.

Each index has two files, one is a header file, and the other is
the index proper. (.HDR and .IDX). The header file contains
information regarding the structure of the index proper. On
opening the index, the header file is read into control
variables, the header is closed, and then the actual index
opened.

The reverse is accomplished when the index is closed: The index
closed, the header opened, and the new updated info is written to
the header file.


CALLING SEQUENCE & PARAMETER LIST

call bit.creatq(fl%,flnm$,key.length%)

WHERE

fl% is the index file number
flnm$ is the eight character index name (mo extension)
key.length% is an integer between 4 & 255


AEBITFIN - SUB PROGRAM

This routine will attempt to find a key matching exactly that of
the item passed to it. Failing that, it will return the 'closest'
match. If a close match is returned, this is indicated by a
negative relative record number for the key.

For programs where 'close' match selection is important, it is
suggested that you use the Key.Select.Box routine in which a list
of keys would be displayed and a scroll selection possible. (It
is quite possible for a user program to use this method to
traverse the whole index).

I am including the comments that lead into this routine in the
documenting file. Please note: this will be done throughout this
document in an effort to cut writing time down, and to make
things clearer ?

Find a key in the index. If the find was a success, then two
values are actually returned. Success% holds the pointer to the
physical position on the index, while mrec% returns the master
record number. The find actually returns a match directly on the
key being looked for. If there was no direct match, then ky$ will
return the match before the return, mrec% will have a minus
record number value, and success% will return the pointer into
the index - for the bit.next and bit.prev routines to use.



CALLING SEQUENCE & PARAMETER LIST

call bit.find(fl%,ky$,mrec%,success%)

WHERE

fl% is the index file number
ky$ is the key to search the index file for
mrec% is the record number ind the indexed file
success% is described above



AEBITINS - SUB PROGRAM

This will allow a key to be inserted into an index. This routine
does not check for duplicates. If duplication checking is needed,
then it's important that you use the FIND routine to see if it's
there. It's up to an application program to check if the key
exists. I've done it this way so that you can decide to make an
index accept duplicate keys or not.

CALLING SEQUENCE & PARAMETER LIST

call bit.ins(fl%,ky$,mrec%,success%)

WHERE

fl% is the index file number
ky$ is the key to insert into the index file
mrec% is the master record number passed to bit.ins
success% is 0 on a failure, 1 if ok



AEBITKIL - SUB PROGRAM

This delete routine is the most complex of those in the indexing
package. If it is changed, it should be done so with great care.
I spent many long hours ensuring that it handled *most*
eventualities. Please be careful!

This routine is usually the most time consuming. This is the only
routine that actually 'moves' records around in the file. This
comes about when you are deleting the master-parent key (record
1) and one of the children needs' to be moved. Also, if you
delete a key in the index and it happens to be the only one
there, then the routine will truncate the file (making future
accesses somewhat faster).

A call to FIND should ALWAYS precede DELETE. This will set up
pointers in memory for DELETE to use.

On return from delete, success% will be zero if the routine
failed, otherwise success% will equal 1.



CALLING SEQUENCE & PARAMETER LIST

call bit.kill(fl%,ky$,mrec%,success%)

WHERE

fl% is the index file number
ky$ is the key to delete into the index file
mrec% is the master record number passed (from bit.find)
success% is 0 on a failure, 1 if ok



AEBITLFT - SUB PROGRAM


Bit.left moves the index pointer so that it references the
smallest key in the tree. This function is to be used to get a
listing of the tree in sequence. The 'bit.right' routine will
position the pointer at the other end of the tree for reverse
listings.

CALLING SEQUENCE & PARAMETER LIST

call bit.left(fl%,ky$,mrec%,success%)

WHERE

fl% is the index file number
ky$ is the key to delete into the index file
mrec% is the master record number passed (from bit.find)
success% is 0 on a failure, 1 if ok


AEBITNEX - SUB PROGRAMS

This routine will return the next key in the index from the
current one. If there are no current values for the key, then a
negative value will be returned, else a positive value indicating
the records - master and index - will be returned (or a zero if
no next key).

CALLING SEQUENCE & PARAMETER LIST

call bit.next(fl%,ky$,mrec%,success%)

WHERE

fl% is the index file number
ky$ is the key to delete into the index file
mrec% is the master record number passed (from bit.find)
success% is 0 on a failure, 1 if ok





AEBITOPE - SUB PROGRAM

This is the ONLY way an index file can be opened. This routine
sets up parameters in memory for subsequent access by other
routines.

CALLING SEQUENCE & PARAMETER LIST

call bit.open(fl%,hn$)

WHERE

fl% is the index file number
hn$ is the name of the index (8 ch, excluding extension)


AEBITPRV - SUB PROGRAM

This is much the same as the 'next' function except that it
returns the key previous to the currently selected one. This can
be usefull for printing a report in reverse sequence.

CALLING SEQUENCE & PARAMETER LIST

call bit.prev(fl%,ky$,mrec%,success%)

WHERE

fl% is the index file number
ky$ is the key to delete into the index file
mrec% is the master record number passed (from bit.find)
success% is 0 on a failure, 1 if ok



AEBITRGT - SUB PROGRAM

Bit.right moves the index pointer so that it references the
largest key in the tree. this function is to be used to get a
listing of the tree in sequence. The 'bit.left' routine will
position the pointer at the other end of the tree for forward
listings.

CALLING SEQUENCE & PARAMETER LIST

call bit.right(fl%,ky$,mrec%,success%) static

WHERE

fl% is the index file number
ky$ is the key to delete into the index file
mrec% is the master record number passed (from bit.find)
success% is 0 on a failure, 1 if ok





AECOMMON - SUB PROGRAM

These COMMON definitions should be placed right at the start of
your programs, with the INCLUDE meta command. Refer to page -188-
of the Microsoft QuickBASIC 2.00 Compiler Guide.




AEGETFLS - SUB PROGRAM

This works in conjunction with the other file accessing routines,
and returns information regarding the OPEN / CLOSED status of a
file.




CALLING SEQUENCE & PARAMETER LIST

call Get.File.Status(fl%,rlen%,st%)

WHERE

fl% is the file number
rlen% is the record length of this file
st% is the status returned (1=OPEN , 2=CLOSED)



AEGETREC - SUB PROGRAM

Allocates and returns the next available record in a file. When
records are deleted, they are pushed on to the top of this stack.

CALLING SEQUENCE & PARAMETER LIST

call Get.Avail.Record (fl%,rlen%,rec%)

WHERE

fl% is the file number
rlen% is the record length
rec% is the record number returned




AEINITFL - SUB PROGRAM

This initializes a new file's header record for subsequent access
with the other record allocation routines.

CALLING SEQUENCE & PARAMETER LIST

call Init.New.File(fl%,rlen%)

WHERE

fl% is the file number
rlen% is the record length



AEMRKCLS - SUB PROGRAM

Mark a file as closed (works with the record number allocation
routines).

CALLING SEQUENCE & PARAMETER LIST

call Mark.File.Closed(fl%,rlen%)

WHERE

fl% is the file number
rlen% is the record length



AEMRKOPE - SUB PROGRAM

Mark a file as open (works with the record number allocation
routines).

CALLING SEQUENCE & PARAMETER LIST

call Mark.File.Open(fl%,rlen%)

WHERE

fl% is the file number
rlen% is the record length



AERELREC - SUB PROGRAM

Release an allocated record (delete) using the record allocation
system.

CALLING SEQUENCE & PARAMETER LIST

call Release.Avail.Record(fl%,rlen%,rec%)

WHERE

fl% is the file number
rlen% is the record length
rec% is the record to release




AESHARED - SUB PROGRAM

To be included in all externally compile sub-programs



IDXTEST4 - PROGRAM

This program is used for testing the indexing routines. It could
also serve as a demonstration of the use of the routines. It is a
hastily put together piece of software so is *very* inelegant. To
use the program, you need to CREATE a file and then OPEN the
file. You can then use the other accessing routines.


NAMES - PROGRAM

Names is a demonstration program of some of the routines in the
program library. It served initially as demo of the indexing
routines, but could be an indication of how the menu and dialog
routines work.






Version Number 1.1, 15 February, 1987 Page 19







 December 11, 2017  Add comments

Leave a Reply