int WNJFile::myCount = 0L;
int Page::gPage = 1;
int BTree::NodeIndexCtr = 0;
int BTree::LeafIndexCtr = 0;
int BTree::NodePageCtr = 0;
int BTree::LeafPageCtr = 0;
int BTree::NodeIndexPerPage[Order+1];
int BTree::LeafIndexPerPage[Order+1];
for (int i = 0; i < Order +1; i++)
{
BTree::NodeIndexPerPage[i] = 0;
BTree::LeafIndexPerPage[i] = 0;
}
char buffer[PageSize+1];
bool fQuit = false;
while ( !fQuit )
{
cout << "?: ";
cin.getline(buffer,PageSize);
if ( buffer[0] == '-' )
{
switch (buffer[1])
{
case '?':
DoFind(buffer+2,myTree);
break;
case '!':
myTree.PrintTree();
break;
case 'F':
case 'f':
ParseFile(myTree);
break;
case '0':
fQuit = true;
break;
}
}
else
{
if ( myTree.Insert(buffer) )
cout << "Inserted.\n";
buffer[0] = '\0';
}
}
return 0;
}
// having found matches, show the menu of choices
// each entry is numbered and dated
void ShowMenu(int *list)
{
int j=0;
char buffer[PageSize+1];
time_t theTime;
int len;
char listBuff[256];
struct tm * ts;
int dispSize;
// handle -? command
// find matches, show the menu, request choice
// display record and redisplay menu
void DoFind(char * searchString, BTree& myTree)
{
// create an array of total set of WNJ
// offsets. This will be used to display
// choices and to find actual text
int list[PageSize];
// initialize the array to all zeros
for (int i = 0; i<PageSize; i++)
list[i] = 0;
int offset = myTree.Find(p1);
if (offset)
{
// get the array of offsets from WNJFile
int *found = BTree::theWNJFile.Find(offset);
int j = 0;
// add any you don't already have
for (;k < PageSize && found[j];j++,k++)
{
for (int l = 0; l < k; l++)
{
if (list[l] == found[j])
continue;
}
list[k] = found [j];
}
delete [] found;
}
cout << "\n";
if (!list[0])
{
cout << "Nothing found.\n";
return;
}
ShowMenu(list);
int choice;
char buffer[PageSize];
int len;
time_t theTime;
for (;;)
{
cout << "Choice (0 to stop): " ;
cin >> choice;
cin.ignore(PageSize,'\n');
if ( choice < 1 )
break;