Class TKey (unit KeyU)

Inherits from

TComponent

Constructors


constructor Create(AOwner: TComponent);

==========================================================} { User interface methods } {==========================================================


Functions

procedure AttachFile;


function ChangeKey(oldkey, newkey: shortstring): boolean;

else just insert 65535 as num

function DeleteKey(killkey: shortstring; IfEmpty: boolean): boolean;

new root needed

destructor Destroy;


procedure DetachFile;

Assume the worst

function ExistKey(sought: shortstring): boolean;

if found is the sentinal at the end of file its first character is chr(255).

function FindKey(sought: shortstring): shortstring;


function FindRatio(sought: shortstring): single;

Adjust ratio to be in the interval [0,1]

function FirstKey: shortstring;


function GetKey(kid: longint): shortstring;


function GetKeyID(key: shortstring): longint;

Set SIA array

function GetRecID(key: shortstring; n: word): longint;


function GetRecIDCount(key: shortstring): word;

These routines deal with record ids.

function IncludeRecID(key: shortstring; rid: longint): boolean;


function InsertKey(newkey: shortstring): boolean;

found a final deleted item

procedure KeyByRatio(ratio: single; var found: shortstring);

The following two routines are used by SelectU.

function LastKey: shortstring;


function NextKey(key: shortstring): shortstring;


function PrevKey(key: shortstring): shortstring;

found a final deleted item

function RemoveRecID(key: shortstring; rid: longint): boolean;

make room for one more.

procedure AddToFreeList(xat: longint; xnum: word);

found a final deleted item

procedure FindItem(k: shortstring; var item: byte; var f: shortstring; var KD: KeyData);

Returns the key and KeyData from KeySector S from place item.

function FindRoom(needed:word): longint;

Now collapse if possible

procedure GetTheKey(var S: KeySector; var k: shortstring; var KD: KeyData; item: byte);

Put the key and KeyData into the KeySector S at place item.

procedure PrimativeFindKey(ByPass: boolean; k: shortstring; var f: shortstring; var KD: KeyData);

binary search is used.

procedure PutInKey(var S: KeySector; k: shortstring; KD: KeyData; item: byte);

Writes Sector S into KeyFile at position Sector.

procedure ReadSector(Sector: word; var S: KeySector);

These procedures are useful but not directly called.

procedure WriteSector(Sector: word; var S: KeySector);

Reads sector Sector into S from KeyFile.

procedure WriteZero;


procedure SetFileName(Value: string);

----------------------------------------------------------------} { } { Methods of Key } { } {----------------------------------------------------------------} {================================================================} { Routines that set properties } {================================================================

procedure SetKeyLength(Value: word);

The following null procedure make the KeyLength visible in the Object Inspector.

procedure SetRecsPerKey(Value: TRecsPerKey);


Properties

property ActiveKeys : longint


property FileName : string


property KeyLength : word


property RecsPerKey : TRecsPerKey


Events

Variables

FreeCount : word;


FreeList : array [1..NumLocs] of Locator;


KeyIDFile : file of word;


KS : KeySector;

make visible to TKey and TMultiKey

PKL : byte;


RecIDFile : file of longint;


SecFile : SectorFile;


SIA : SectorInfoArray;


Active : longint;


FFileName : string;


FirstSector : word;


FKeyAttached : boolean;


FRecsPerKey : TRecsPerKey;


KeepNumber : byte;

When splitting a sector

KL : word;


NextID : longint;


RootLevel : byte;


RootSector : word;


SendNumber : byte;



Constructors


constructor Create(AOwner: TComponent);

==========================================================} { User interface methods } {==========================================================


Functions


procedure AttachFile;


function ChangeKey(oldkey, newkey: shortstring): boolean;

else just insert 65535 as num


function DeleteKey(killkey: shortstring; IfEmpty: boolean): boolean;

new root needed


destructor Destroy;


procedure DetachFile;

Assume the worst


function ExistKey(sought: shortstring): boolean;

if found is the sentinal at the end of file its first character is chr(255).


function FindKey(sought: shortstring): shortstring;


function FindRatio(sought: shortstring): single;

Adjust ratio to be in the interval [0,1]


function FirstKey: shortstring;


function GetKey(kid: longint): shortstring;


function GetKeyID(key: shortstring): longint;

Set SIA array


function GetRecID(key: shortstring; n: word): longint;


function GetRecIDCount(key: shortstring): word;

These routines deal with record ids.


function IncludeRecID(key: shortstring; rid: longint): boolean;


function InsertKey(newkey: shortstring): boolean;

found a final deleted item


procedure KeyByRatio(ratio: single; var found: shortstring);

The following two routines are used by SelectU. Do not use.


function LastKey: shortstring;


function NextKey(key: shortstring): shortstring;


function PrevKey(key: shortstring): shortstring;

found a final deleted item


function RemoveRecID(key: shortstring; rid: longint): boolean;

make room for one more.


procedure AddToFreeList(xat: longint; xnum: word);

found a final deleted item


procedure FindItem(k: shortstring; var item: byte; var f: shortstring; var KD: KeyData);

Returns the key and KeyData from KeySector S from place item.


function FindRoom(needed:word): longint;

Now collapse if possible


procedure GetTheKey(var S: KeySector; var k: shortstring; var KD: KeyData; item: byte);

Put the key and KeyData into the KeySector S at place item.


procedure PrimativeFindKey(ByPass: boolean; k: shortstring; var f: shortstring; var KD: KeyData);

binary search is used.


procedure PutInKey(var S: KeySector; k: shortstring; KD: KeyData; item: byte);

Writes Sector S into KeyFile at position Sector.


procedure ReadSector(Sector: word; var S: KeySector);

These procedures are useful but not directly called.


procedure WriteSector(Sector: word; var S: KeySector);

Reads sector Sector into S from KeyFile.


procedure WriteZero;


procedure SetFileName(Value: string);

----------------------------------------------------------------} { } { Methods of Key } { } {----------------------------------------------------------------} {================================================================} { Routines that set properties } {================================================================


procedure SetKeyLength(Value: word);

The following null procedure make the KeyLength visible in the Object Inspector. Of course it is not to be changed.


procedure SetRecsPerKey(Value: TRecsPerKey);


Properties


property ActiveKeys : longint


property FileName : string


property KeyLength : word


property RecsPerKey : TRecsPerKey


Events


Variables


FreeCount : word;


FreeList : array [1..NumLocs] of Locator;


KeyIDFile : file of word;


KS : KeySector;

make visible to TKey and TMultiKey


PKL : byte;


RecIDFile : file of longint;


SecFile : SectorFile;


SIA : SectorInfoArray;


Active : longint;


FFileName : string;


FirstSector : word;


FKeyAttached : boolean;


FRecsPerKey : TRecsPerKey;


KeepNumber : byte;

When splitting a sector


KL : word;


NextID : longint;


RootLevel : byte;


RootSector : word;


SendNumber : byte;